/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --font-display: 'Space Grotesk', sans-serif;

    --ink: #1f1c17;
    --muted: #6f675d;
    --muted-2: #8b8378;

    --brand: #0f766e;
    --brand-dark: #0b5d58;
    --accent: #f59e0b;
    --accent-soft: #fff2d6;

    --bg: #f7f3ed;
    --surface: #ffffff;
    --surface-2: #fefbf7;
    --border: #e8e0d6;

    --sidebar-bg: #0f1a23;
    --sidebar-text: #b8c7c3;
    --sidebar-active: #ffffff;

    --success-bg: #ddf5ea;
    --success-text: #0f5a46;
    --danger-bg: #ffe3e0;
    --danger-text: #9c2f2f;
    --warning-bg: #fff2d6;
    --warning-text: #945c00;

    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--ink);
    background: radial-gradient(900px circle at 12% -10%, #ffe6b5 0%, transparent 55%),
        radial-gradient(800px circle at 90% 0%, #c9f2ec 0%, transparent 50%),
        var(--bg);
    display: flex;
}

body.sidebar-open {
    overflow: hidden;
}

body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(0);
    pointer-events: none;
    z-index: 0;
}

body::before {
    width: 420px;
    height: 420px;
    right: -140px;
    top: 20vh;
    background: radial-gradient(circle, rgba(15, 118, 110, 0.18), transparent 65%);
}

body::after {
    width: 520px;
    height: 520px;
    left: -200px;
    bottom: -220px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.18), transparent 65%);
}

body.auth {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}

.sidebar,
.main,
.auth-shell {
    position: relative;
    z-index: 1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    margin: 0 0 1rem 0;
    color: var(--ink);
    line-height: 1.2;
}

p {
    margin: 0 0 1rem 0;
    color: var(--muted);
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

img {
    max-width: 100%;
    display: block;
}

/* Sidebar */
.sidebar {
    width: 260px;
    padding: 26px 20px;
    background:
        radial-gradient(520px circle at -20% -30%, rgba(16, 185, 129, 0.18), transparent 60%),
        radial-gradient(420px circle at 120% 10%, rgba(245, 158, 11, 0.18), transparent 55%),
        var(--sidebar-bg);
    color: var(--sidebar-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    align-self: flex-start;
}

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(247, 243, 237, 0.92);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 220;
    backdrop-filter: blur(10px);
}

.mobile-brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
}

.burger {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 210;
}

.sidebar h2 {
    font-size: 20px;
    color: #fff;
    margin: 0;
}

.sidebar h2 span {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
}

.sidebar .sidebar-meta {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

.sidebar .sidebar-meta strong {
    color: #fff;
    font-weight: 600;
    word-break: break-word;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    color: var(--sidebar-text);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.sidebar a::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    flex: 0 0 10px;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-active);
}

.sidebar a.active {
    background: rgba(255, 255, 255, 0.14);
    color: var(--sidebar-active);
}

.sidebar a[href*="dashboard"]::before {
    background: linear-gradient(135deg, #22d3ee, #0ea5e9);
}

.sidebar a[href*="new"],
.sidebar a[href*="create"],
.sidebar a[href*="edit"] {
    color: #e6f4ff;
}

.sidebar a[href*="new"]::before,
.sidebar a[href*="create"]::before {
    background: linear-gradient(135deg, #34d399, #10b981);
}

.sidebar a[href*="settings"]::before {
    background: linear-gradient(135deg, #fbbf24, #f97316);
}

.sidebar a[href*="customers"]::before {
    background: linear-gradient(135deg, #a855f7, #ec4899);
}

.sidebar a[href*="account"]::before {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
}

.sidebar a[href*="password"]::before {
    background: linear-gradient(135deg, #fb7185, #f43f5e);
}

.sidebar a[href*="logout"]::before {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.sidebar .sidebar-footer {
    margin-top: auto;
}

/* Main */
.main {
    flex: 1;
    padding: 36px 40px 64px;
    min-width: 0;
    animation: pageIn 0.45s ease both;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-size: clamp(1.6rem, 2.2vw, 2.2rem);
    margin-bottom: 6px;
}

.page-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
}

/* Panels & Cards */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
}

.panel.compact {
    padding: 20px;
}

.search-panel {
    margin-bottom: 18px;
}

.form-card {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

.card-stack {
    display: grid;
    gap: 20px;
}

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    animation: riseIn 0.5s ease both;
}

.kpi-card:nth-child(2) { animation-delay: 0.05s; }
.kpi-card:nth-child(3) { animation-delay: 0.1s; }
.kpi-card:nth-child(4) { animation-delay: 0.15s; }
.kpi-card:nth-child(5) { animation-delay: 0.2s; }

.kpi-card::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.08;
    background: linear-gradient(135deg, transparent, currentColor);
}

.kpi-card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-2);
    margin-bottom: 8px;
}

.kpi-card p {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    color: inherit;
}

.kpi-card.tone-teal { color: #0f766e; }
.kpi-card.tone-emerald { color: #059669; }
.kpi-card.tone-rose { color: #e11d48; }
.kpi-card.tone-amber { color: #b45309; }
.kpi-card.tone-slate { color: #334155; }

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.2);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(15, 118, 110, 0.25);
}

.btn-secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn-secondary:hover {
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid transparent;
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 12px 24px rgba(239, 68, 68, 0.2);
}

.btn-xs {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* Forms */
form {
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 44px;
}

.eye-toggle {
    cursor: pointer;
    position: absolute;
    right: 14px;
    top: 16px;
    font-size: 16px;
    color: var(--muted-2);
}

.strength-bar {
    height: 6px;
    width: 100%;
    background: #efe9e1;
    margin-top: 6px;
    border-radius: 999px;
    overflow: hidden;
}

.strength-bar-inner {
    height: 100%;
    width: 0;
    transition: width 0.3s;
    background: #ef4444;
}

.form-row {
    display: grid;
    gap: 12px;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.6);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
    background: #fff;
}

.input-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-inline input {
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.95rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.hidden-field {
    display: none;
}

/* Tables */
.table-wrapper {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: #fbfaf7;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--ink);
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #fefcf8;
}

.table-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-action {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand);
}

.link-action:hover {
    text-decoration: underline;
}

/* Badges & Status */
.badge {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.status-text {
    font-size: 0.85rem;
    font-weight: 600;
}

.status-expired { color: #b42318; }
.status-cancelled { color: #a16207; }
.status-active { color: #15803d; }

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active,
.tab-btn:hover {
    color: var(--ink);
    border-color: rgba(15, 118, 110, 0.4);
    box-shadow: 0 10px 20px rgba(15, 118, 110, 0.12);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Notices */
.notice {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.notice-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: rgba(15, 118, 110, 0.2);
}

.notice-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: rgba(239, 68, 68, 0.2);
}

.notice-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: rgba(245, 158, 11, 0.25);
}

.nooking-notice {
    background: #e8f2ff;
    color: #1e3a8a;
    border: 1px solid rgba(30, 58, 138, 0.15);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.description {
    color: var(--muted);
    font-size: 0.9rem;
}

/* Auth */
.auth-shell {
    width: min(980px, 92vw);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 28px;
    align-items: center;
}

.auth-shell-single {
    grid-template-columns: 1fr;
    max-width: 520px;
    margin: 0 auto;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 36px;
    animation: pageIn 0.5s ease both;
}

.auth-aside {
    background: linear-gradient(160deg, #0f766e, #0b3b3a);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 32px;
    position: relative;
    overflow: hidden;
    min-height: 320px;
}

.auth-aside::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(360px circle at 20% 10%, rgba(255, 255, 255, 0.2), transparent 55%);
    opacity: 0.8;
}

.auth-aside > * {
    position: relative;
    z-index: 1;
}

.auth-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--brand);
    font-family: var(--font-display);
    margin-bottom: 6px;
}

.auth-title {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.auth-links {
    margin-top: 14px;
    font-size: 0.9rem;
    color: var(--muted);
}

.auth-links a {
    color: var(--brand);
    font-weight: 600;
}

.cf-turnstile {
    margin: 8px 0;
}

/* Price list */
.price-list {
    display: grid;
    gap: 10px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    max-height: 420px;
    overflow-y: auto;
}

.price-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #faf8f5;
}

.price-item:hover {
    border-color: rgba(15, 118, 110, 0.2);
    background: #fff;
}

.price-item input {
    margin-top: 2px;
}

.price-id {
    font-size: 0.75rem;
    color: var(--muted-2);
    margin-top: 2px;
}

/* Customer license table helpers */
.domain-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.domain-form input {
    max-width: 100%;
}

.domain-input {
    width: 100%;
    min-width: var(--domain-ch, 20ch);
}

.license-key-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.license-key-text {
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.license-price {
    font-size: 0.75rem;
    color: var(--muted-2);
    margin-top: 6px;
}

.copy-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.copy-btn:hover {
    color: var(--ink);
    border-color: rgba(15, 118, 110, 0.4);
    box-shadow: 0 6px 12px rgba(15, 118, 110, 0.12);
}

.copy-btn.copied {
    color: #15803d;
    border-color: rgba(21, 128, 61, 0.4);
}

.inline-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-buttons form {
    margin: 0;
}

/* Details list */
.details-list {
    margin: 6px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

details summary {
    cursor: pointer;
    font-weight: 600;
}

/* Login notices */
.error {
    color: #b42318;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1100px) {
    .main {
        padding: 32px 28px 56px;
    }
}

@media (max-width: 900px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        z-index: 230;
        box-shadow: 0 24px 40px rgba(15, 23, 42, 0.3);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-topbar {
        display: flex;
    }

    .main {
        padding: 20px 18px 44px;
    }

    table { min-width: 760px; }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        order: -1;
    }
}

@media (max-width: 600px) {
    .page-header {
        align-items: flex-start;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .table-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel {
        padding: 22px;
    }

    .auth-card {
        padding: 28px;
    }

    table { min-width: 720px; }
}
