/* =============================================================
   Jooli Admin - core stylesheet
   Fashion-forward design system. Light by default with warm cream,
   light gold and blush-pink accents. Dark mode is also supported.
   ============================================================= */

/* ---------- Design tokens ---------- */
:root {
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                    Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-display: 'Playfair Display', 'Inter', Georgia, serif;
    --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --transition: 200ms cubic-bezier(.4, 0, .2, 1);

    /* brand gradients used for accents */
    --grad-brand:   linear-gradient(135deg, #d4b07a 0%, #d8a3a0 55%, #e7c6c0 100%);
    --grad-brand-2: linear-gradient(135deg, #e3c489 0%, #e6b4ad 100%);
    --grad-soft:    linear-gradient(135deg, #fbf0dd 0%, #fbe2dc 100%);
}

/* ---------- Light theme (DEFAULT) ---------- */
:root,
[data-theme="light"] {
    color-scheme: light;

    --bg:           #fbf8f2;    /* warm cream background */
    --bg-2:         #f6f1e6;
    --surface:      #ffffff;    /* white cards */
    --surface-2:    #f7f3ea;    /* subtle warm cream */
    --surface-3:    #efe8d8;    /* slightly deeper */
    --border:       #ece4d2;    /* champagne edge */
    --border-2:     #ddd2b9;
    --text:         #2a241c;    /* warm near-black */
    --text-muted:   #857c6e;    /* warm grey */
    --text-dim:     #a89e8d;
    --primary:      #b8945e;    /* light gold */
    --primary-2:    #a07a45;    /* deeper gold */
    --primary-soft: #f4e7cd;    /* gold-tinted background */
    --accent:       #d49892;    /* dusty pink */
    --accent-soft:  #f6dcd6;
    --pink:         #e7b9b2;
    --success:      #7fa285;
    --success-soft: #e0ecdf;
    --warning:      #d49b5a;
    --warning-soft: #f7e3c5;
    --danger:       #c87878;
    --danger-soft:  #f4d8d6;
    --info:         #8aa5b8;
    --info-soft:    #dde6ec;

    --shadow-sm:    0 1px 2px rgba(56, 42, 22, .06);
    --shadow:       0 8px 24px rgba(56, 42, 22, .08);
    --shadow-lg:    0 24px 60px rgba(56, 42, 22, .14);

    --sidebar-bg:   rgba(255, 252, 246, .85);
    --topbar-bg:    rgba(255, 252, 246, .72);
    --glass-bd:     rgba(56, 42, 22, .06);

    /* ambient gradient blobs */
    --aurora-1: rgba(216, 168, 96, .22);   /* gold */
    --aurora-2: rgba(231, 185, 178, .28);  /* blush */
    --aurora-3: rgba(245, 220, 195, .26);  /* cream */
}

/* ---------- Optional dark theme ---------- */
[data-theme="dark"] {
    color-scheme: dark;

    --bg:           #1a1612;
    --bg-2:         #221c16;
    --surface:      #26201a;
    --surface-2:    #2e2720;
    --surface-3:    #382f26;
    --border:       #3a3128;
    --border-2:     #4b4035;
    --text:         #f4ede1;
    --text-muted:   #b9ad99;
    --text-dim:     #8a7f6c;
    --primary:      #d4b07a;
    --primary-2:    #c69961;
    --primary-soft: #3a2e1e;
    --accent:       #e7b9b2;
    --accent-soft:  #43302b;
    --pink:         #f4d8d2;
    --success:      #9ec4a4;
    --success-soft: #2c3a2e;
    --warning:      #e9b97a;
    --warning-soft: #3f3019;
    --danger:       #e69b9b;
    --danger-soft:  #3f2222;
    --info:         #b1c5d6;
    --info-soft:    #20303a;

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, .35);
    --shadow:       0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg:    0 24px 60px rgba(0, 0, 0, .55);

    --sidebar-bg:   rgba(28, 22, 16, .85);
    --topbar-bg:    rgba(28, 22, 16, .65);
    --glass-bd:     rgba(255, 255, 255, .05);

    --aurora-1: rgba(216, 168, 96, .18);
    --aurora-2: rgba(231, 185, 178, .14);
    --aurora-3: rgba(245, 220, 195, .10);
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a { color: var(--primary-2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

::selection { background: var(--primary-soft); color: var(--text); }

/* ambient gradient blobs in background */
body::before,
body::after {
    content: '';
    position: fixed;
    pointer-events: none;
    z-index: 0;
    filter: blur(140px);
    opacity: .9;
    border-radius: 50%;
}
body::before {
    width: 560px; height: 560px;
    background: var(--aurora-1);
    top: -220px; left: -140px;
}
body::after {
    width: 520px; height: 520px;
    background: var(--aurora-2);
    bottom: -240px; right: -140px;
}

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: padding-box; }

/* =============================================================
   App shell
   ============================================================= */
.app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 270px 1fr;
    grid-template-rows: 68px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
    transition: grid-template-columns var(--transition);
}
.app.sidebar-collapsed {
    grid-template-columns: 80px 1fr;
}

/* ---------- Sidebar ---------- */
.sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 30;
}

.sidebar-brand {
    height: 68px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand-mark {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--grad-brand);
    display: grid;
    place-items: center;
    color: white;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 8px 20px rgba(212, 176, 122, .35);
    flex-shrink: 0;
    letter-spacing: -0.02em;
}
.brand-text {
    display: flex; flex-direction: column; line-height: 1.1;
    overflow: hidden;
}
.brand-text strong {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.brand-text span {
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    white-space: nowrap;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
}
.sidebar-section {
    padding: 16px 12px 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    white-space: nowrap;
}
.sidebar-section:first-child { padding-top: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13.5px;
    position: relative;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item .nav-icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    stroke-width: 1.75;
}
.nav-item.is-active {
    color: var(--text);
    background: linear-gradient(135deg,
        rgba(216, 168, 96, .16) 0%,
        rgba(231, 185, 178, .14) 100%);
    box-shadow: inset 0 0 0 1px var(--glass-bd);
}
.nav-item.is-active::before {
    content: '';
    position: absolute;
    left: -12px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px;
    border-radius: 0 4px 4px 0;
    background: var(--grad-brand);
}
.nav-item.is-active .nav-icon { color: var(--primary-2); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: background var(--transition);
}
.user-card:hover { background: var(--surface-3); }
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--grad-brand-2);
    color: white;
    font-weight: 600;
    font-family: var(--font-display);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 14px;
}
.user-info {
    overflow: hidden;
    line-height: 1.2;
    flex: 1;
}
.user-info strong {
    font-size: 13px; font-weight: 600;
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.user-info span {
    font-size: 11.5px; color: var(--text-muted);
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Collapsed sidebar */
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .sidebar-section,
.app.sidebar-collapsed .user-info {
    display: none;
}
.app.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.app.sidebar-collapsed .nav-item      { justify-content: center; padding: 12px; }
.app.sidebar-collapsed .nav-item.is-active::before { display: none; }
.app.sidebar-collapsed .user-card     { justify-content: center; padding: 6px; }

/* ---------- Topbar ---------- */
.topbar {
    grid-area: topbar;
    position: sticky;
    top: 0;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    background: var(--topbar-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    z-index: 20;
}
.icon-btn {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    text-decoration: none;
}
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.75; }

.topbar-search {
    flex: 1;
    max-width: 460px;
    position: relative;
}
.topbar-search input {
    width: 100%;
    height: 42px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 0 14px 0 44px;
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.topbar-search input::placeholder { color: var(--text-dim); }
.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.topbar-search svg {
    position: absolute;
    left: 16px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    width: 16px; height: 16px;
}
.topbar-search kbd {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10.5px;
    padding: 3px 6px;
    border-radius: 6px;
    font-family: inherit;
}

.topbar-actions {
    display: flex; align-items: center; gap: 8px; margin-left: auto;
}

/* ---------- Main content & page header ---------- */
.main {
    grid-area: main;
    padding: 32px 36px 56px;
    min-width: 0;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}
.page-title {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 13.5px;
    margin-top: 4px;
}
.page-actions {
    display: flex; gap: 10px; align-items: center;
}
.page-actions .inline-form { display: inline; margin: 0; padding: 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}
.card-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 0;
}

/* dashboard "welcome" hero card */
.welcome-card {
    background:
        linear-gradient(135deg, rgba(244, 231, 205, .55) 0%, rgba(246, 220, 214, .45) 100%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    position: relative;
    overflow: hidden;
}
.welcome-card::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 220px; height: 220px;
    background: var(--grad-brand);
    border-radius: 50%;
    filter: blur(60px);
    opacity: .25;
}
.welcome-row {
    display: flex; align-items: center; gap: 16px; margin-top: 14px;
    position: relative; z-index: 1;
}
.welcome-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--primary-2);
    display: grid; place-items: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.welcome-icon svg { width: 22px; height: 22px; }
.welcome-text strong { display: block; font-weight: 600; }
.welcome-text span { color: var(--text-muted); font-size: 12.5px; }

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
}
.stat::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--grad-soft);
    opacity: .35;
    pointer-events: none;
}
.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 12px;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}
.stat-delta {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    background: var(--success-soft);
    color: var(--success);
}
.stat-delta.down { background: var(--danger-soft); color: var(--danger); }
.stat-icon {
    position: absolute;
    top: 22px; right: 22px;
    width: 42px; height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-2);
    display: grid;
    place-items: center;
}
.stat-icon svg { width: 20px; height: 20px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--grad-brand);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(212, 176, 122, .35);
}
/* Re-assert background on hover so the generic .btn:hover rule doesn't
   replace the gradient with the neutral surface colour (which would make
   the white label disappear against a cream background). */
.btn-primary:hover {
    background: var(--grad-brand);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 14px 30px rgba(212, 176, 122, .45);
    filter: brightness(1.04);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    border-color: transparent;
}
.btn-danger:hover {
    background: #b86464;
    color: #ffffff;
    border-color: transparent;
}

.btn-sm    { height: 34px; padding: 0 14px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
/* Only the direct-child <label> gets the form-label styling, so it
   doesn't bleed into <label class="switch"> or <label class="check-card">
   nested deeper in the field. */
.field > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.input, .select, .textarea {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.input::placeholder { color: var(--text-dim); }

.input-group { position: relative; }
.input-group .input { padding-left: 44px; }
.input-group .input-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    width: 16px; height: 16px;
}

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--danger-soft);  border-color: rgba(200,120,120,.35); color: #8d4848; }
.alert-success { background: var(--success-soft); border-color: rgba(127,162,133,.35); color: #46673f; }
.alert-info    { background: var(--info-soft);    border-color: rgba(138,165,184,.35); color: #4a5e6e; }
.alert-warning { background: var(--warning-soft); border-color: rgba(212,155,90,.35);  color: #8a5a26; }

[data-theme="dark"] .alert-danger  { color: var(--danger); }
[data-theme="dark"] .alert-success { color: var(--success); }
[data-theme="dark"] .alert-info    { color: var(--info); }
[data-theme="dark"] .alert-warning { color: var(--warning); }

/* ---------- Auth (login) page ---------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    z-index: 1;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 40px 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.auth-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--grad-brand);
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}
.auth-brand h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.auth-brand span { display: block; color: var(--text-muted); font-size: 12px; }

.auth-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}
.auth-subtitle {
    color: var(--text-muted);
    font-size: 13.5px;
    margin: 0 0 24px;
}
.auth-footer {
    text-align: center;
    margin-top: 22px;
    color: var(--text-dim);
    font-size: 12px;
}

/* aurora blobs for auth & install backgrounds */
.auth-aurora {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.auth-aurora::before,
.auth-aurora::after,
.auth-aurora div {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
}
.auth-aurora::before {
    content: '';
    width: 580px; height: 580px;
    background: var(--aurora-1);
    top: -140px; left: -120px;
    animation: float 14s ease-in-out infinite;
}
.auth-aurora::after {
    content: '';
    width: 500px; height: 500px;
    background: var(--aurora-2);
    bottom: -200px; right: -140px;
    animation: float 18s ease-in-out infinite reverse;
}
.auth-aurora div {
    width: 440px; height: 440px;
    background: var(--aurora-3);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    opacity: .8;
    animation: float 22s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(40px, -30px); }
}

/* ---------- Install page ---------- */
.install-shell {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 32px;
    position: relative;
    z-index: 1;
}
.install-card {
    width: 100%;
    max-width: 820px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}
.install-header {
    display: flex; align-items: center; gap: 14px; margin-bottom: 24px;
}
.install-header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 24px;
    letter-spacing: -0.01em;
}
.install-header span { color: var(--text-muted); font-size: 13px; display: block; }

.install-log {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    max-height: 340px;
    overflow-y: auto;
}
.install-log .row {
    display: flex; gap: 10px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border);
}
.install-log .row:last-child { border-bottom: 0; }
.install-log .tag {
    width: 48px;
    flex-shrink: 0;
    text-align: center;
    border-radius: 6px;
    font-size: 10.5px;
    padding: 2px 0;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.install-log .tag-ok   { background: var(--success-soft); color: #46673f; }
.install-log .tag-warn { background: var(--warning-soft); color: #8a5a26; }
.install-log .tag-err  { background: var(--danger-soft);  color: #8d4848; }
[data-theme="dark"] .install-log .tag-ok   { color: var(--success); }
[data-theme="dark"] .install-log .tag-warn { color: var(--warning); }
[data-theme="dark"] .install-log .tag-err  { color: var(--danger); }

.install-creds {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    margin-top: 18px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
}
.install-creds b { color: var(--primary-2); }
.install-creds .hint {
    margin-top: 10px;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-muted);
}

.install-actions {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px;
}
.install-note {
    margin-top: 18px;
    font-size: 12px;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.install-note svg { width: 14px; height: 14px; }

/* ---------- 403 / error page ---------- */
.error-page {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
}
.error-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px 56px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 480px;
}
.error-card h1 {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 72px;
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.error-card p { color: var(--text-muted); margin: 0 0 24px; }
.error-card a {
    color: var(--primary-2);
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 10px;
    transition: all var(--transition);
}
.error-card a:hover { background: var(--surface-2); }

/* ---------- Misc utility ---------- */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.muted   { color: var(--text-muted); }
.dim     { color: var(--text-dim); }
.center  { text-align: center; }
.right   { text-align: right; }
.mt-0    { margin-top: 0 !important; }
.mt-1    { margin-top: 4px !important; }
.mt-2    { margin-top: 8px !important; }
.mt-3    { margin-top: 12px !important; }
.mt-4    { margin-top: 16px !important; }
.ml-1    { margin-left: 4px !important; }
.ml-2    { margin-left: 8px !important; }
.mb-0    { margin-bottom: 0 !important; }

.window-arrow { width: 12px; height: 12px; vertical-align: middle; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.row-flex-end { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.switch-group { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.font-mono { font-family: var(--font-mono); }
.full-width { width: 100%; }

/* =============================================================
   Flash messages (rendered by includes/layouts/flash.php)
   ============================================================= */
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13.5px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.flash svg { width: 18px; height: 18px; flex-shrink: 0; }
.flash-success { background: var(--success-soft); border-color: rgba(127,162,133,.4); color: #46673f; }
.flash-danger  { background: var(--danger-soft);  border-color: rgba(200,120,120,.4); color: #8d4848; }
.flash-info    { background: var(--info-soft);    border-color: rgba(138,165,184,.4); color: #4a5e6e; }
.flash-warning { background: var(--warning-soft); border-color: rgba(212,155,90,.4);  color: #8a5a26; }

/* =============================================================
   Toolbar (search + filter + primary action above tables)
   ============================================================= */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.toolbar-search {
    flex: 1 1 280px;
    min-width: 240px;
    max-width: 420px;
    position: relative;
}
.toolbar-search .input { padding-left: 42px; }
.toolbar-search .input-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    width: 16px; height: 16px;
}
.toolbar-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}
.toolbar-actions { margin-left: auto; display: flex; gap: 10px; }

/* Inside the toolbar, form controls auto-size instead of stretching
   to 100 % (the default for `.input` / `.select`). Selects get a
   comfortable min-width; date pickers and short inputs auto-size to
   their content. */
.toolbar .select,
.toolbar select.select { width: auto; min-width: 160px; }
.toolbar-filters .input,
.toolbar-filters input.input { width: auto; min-width: 150px; }
.toolbar-filters input[type="date"].input {
    min-width: 150px;
    flex: 0 0 auto;
}
.toolbar-filters .btn { flex: 0 0 auto; }

/* "From / To" date pickers — a small label glued in front of the input
   so the toolbar reads naturally instead of two anonymous mm/dd/yyyy
   boxes. The pair behaves like a single chip. */
.toolbar-date {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 0 12px;
    height: 44px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    flex: 0 0 auto;
    transition: border-color var(--transition);
}
.toolbar-date:focus-within { border-color: var(--primary); }
.toolbar-date__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.toolbar-date .input,
.toolbar-date input.input {
    border: 0;
    height: 42px;
    padding: 0;
    background: transparent;
    min-width: 130px;
    width: 130px;
    box-shadow: none;
}
.toolbar-date .input:focus,
.toolbar-date input.input:focus { box-shadow: none; border: 0; }

/* =============================================================
   Data table
   ============================================================= */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.data-table thead th {
    text-align: left;
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Sortable column header (used by tables that support order toggles). */
.data-table thead th .th-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    transition: color .15s ease;
}
.data-table thead th .th-sort:hover { color: var(--text); }
.data-table thead th .th-sort.is-active { color: var(--primary); }
.data-table thead th .th-sort svg {
    width: 12px;
    height: 12px;
    opacity: .65;
}
.data-table thead th .th-sort.is-active svg { opacity: 1; }
.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .cell-main { font-weight: 600; }
.data-table .cell-sub  { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.data-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

/* small square thumbnail used in tables */
.thumb {
    width: 44px; height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: block;
}
.thumb-placeholder {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-2);
    display: grid; place-items: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.thumb-placeholder svg { width: 18px; height: 18px; }

/* row avatar + name combo */
.user-cell {
    display: flex; align-items: center; gap: 12px;
}
.user-cell .avatar {
    width: 36px; height: 36px;
    border-radius: 12px;
    background: var(--grad-brand-2);
    color: white;
    font-weight: 600;
    font-family: var(--font-display);
    display: grid; place-items: center;
    flex-shrink: 0;
    font-size: 13px;
}
.user-cell .info strong {
    display: block;
    font-weight: 600;
    font-size: 13.5px;
}
.user-cell .info span {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
}

/* small action buttons used inside table rows */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    margin-left: 4px;
}
.action-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-2);
}
.action-btn.is-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(200,120,120,.4);
}
.action-btn svg { width: 15px; height: 15px; }

/* =============================================================
   Empty state
   ============================================================= */
.empty-state {
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state .icon {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary-2);
    display: grid; place-items: center;
}
.empty-state .icon svg { width: 24px; height: 24px; }
.empty-state h3 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--text);
    margin: 0 0 4px;
}
.empty-state p { margin: 0; font-size: 13.5px; }

/* =============================================================
   Pagination
   ============================================================= */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.pager-info { color: var(--text-muted); font-size: 13px; }
.pager-controls { display: flex; gap: 6px; align-items: center; }
.pager-controls a, .pager-controls span.current {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition);
}
.pager-controls a:hover {
    background: var(--surface-2);
    color: var(--text);
}
.pager-controls .current {
    background: var(--grad-brand);
    border-color: transparent;
    color: white;
    font-weight: 600;
}
.pager-controls a.is-disabled {
    opacity: .4;
    pointer-events: none;
}
.pager-controls .ellipsis {
    min-width: 24px;
    color: var(--text-dim);
    text-align: center;
    user-select: none;
}

/* =============================================================
   Badge / chip / pill
   ============================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.badge-gold    { background: var(--primary-soft); color: var(--primary-2); border-color: rgba(184,148,94,.25); }
.badge-blush   { background: var(--accent-soft);  color: #a05c52; border-color: rgba(212,152,146,.3); }
.badge-success { background: var(--success-soft); color: #46673f; border-color: rgba(127,162,133,.3); }
.badge-danger  { background: var(--danger-soft);  color: #8d4848; border-color: rgba(200,120,120,.3); }
.badge-info    { background: var(--info-soft);    color: #4a5e6e; border-color: rgba(138,165,184,.3); }
.badge-warning { background: var(--warning-soft); color: #8a5a26; border-color: rgba(212,155,90,.3); }
.badge-muted   { background: var(--surface-2);    color: var(--text-dim); }
/* legacy inline status dot - kept hidden so old markup doesn't break */
.badge .dot { display: none; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* =============================================================
   Tag badge (used by Product Tags module & the storefront).
   Driven by two class axes: .color-* and .style-* (solid|soft|outline).
   The .color-* class sets a single --tag-fg variable; the .style-*
   class decides how that variable maps to bg / fg / border.
   ============================================================= */
.tag-badge {
    --tag-fg: var(--text-muted);
    --tag-bg: var(--surface-2);
    --tag-border: var(--border);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--tag-bg);
    color: var(--tag-fg);
    border: 1px solid var(--tag-border);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
}
.tag-badge svg { width: 13px; height: 13px; flex-shrink: 0; }
.tag-badge.size-lg { padding: 8px 16px; font-size: 13.5px; }
.tag-badge.size-lg svg { width: 15px; height: 15px; }

/* colour tokens — pair with one of the style-* modifiers */
.tag-badge.color-gold     { --tag-fg: #b8945e; --tag-bg: var(--primary-soft); --tag-border: rgba(184,148,94,.3); }
.tag-badge.color-blush    { --tag-fg: #a05c52; --tag-bg: var(--accent-soft);  --tag-border: rgba(212,152,146,.35); }
.tag-badge.color-success  { --tag-fg: #5d8253; --tag-bg: var(--success-soft); --tag-border: rgba(127,162,133,.35); }
.tag-badge.color-danger   { --tag-fg: #a25555; --tag-bg: var(--danger-soft);  --tag-border: rgba(200,120,120,.35); }
.tag-badge.color-info     { --tag-fg: #5d738a; --tag-bg: var(--info-soft);    --tag-border: rgba(138,165,184,.35); }
.tag-badge.color-warning  { --tag-fg: #a06c34; --tag-bg: var(--warning-soft); --tag-border: rgba(212,155,90,.35); }
.tag-badge.color-muted    { --tag-fg: var(--text-dim); --tag-bg: var(--surface-2); --tag-border: var(--border); }
.tag-badge.color-charcoal { --tag-fg: #2f2c28; --tag-bg: #e9e3d7; --tag-border: rgba(47,44,40,.18); }

/* style modifiers */
.tag-badge.style-solid {
    background: var(--tag-fg);
    color: #ffffff;
    border-color: transparent;
}
.tag-badge.style-outline {
    background: transparent;
    color: var(--tag-fg);
    border-color: var(--tag-fg);
}
/* .style-soft uses the default tokens above */

/* =============================================================
   Swatch picker (used in the Product Tag form to choose a colour)
   ============================================================= */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px;
}
.swatch {
    position: relative;
    cursor: pointer;
    user-select: none;
}
.swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.swatch .chip {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border-radius: 12px;
    border: 2px solid transparent;
    background: var(--swatch-color, var(--border));
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}
.swatch .chip[data-fg="dark"] { color: #2b2b2b; }
.swatch:hover .chip { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,.08); }
.swatch input:checked + .chip {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}
.swatch input:focus-visible + .chip { outline: 2px solid var(--primary); outline-offset: 2px; }

/* swatch colour tokens — kept in sync with .tag-badge.color-* above */
.swatch.color-gold     .chip { --swatch-color: #b8945e; }
.swatch.color-blush    .chip { --swatch-color: #c98c83; }
.swatch.color-success  .chip { --swatch-color: #7fa285; }
.swatch.color-danger   .chip { --swatch-color: #c87878; }
.swatch.color-info     .chip { --swatch-color: #8aa5b8; }
.swatch.color-warning  .chip { --swatch-color: #d49b5a; }
.swatch.color-muted    .chip { --swatch-color: #cbc4b6; color: #4f4a40; }
.swatch.color-charcoal .chip { --swatch-color: #2f2c28; }

/* =============================================================
   Style picker (segmented control for solid / soft / outline)
   ============================================================= */
.style-picker {
    display: inline-flex;
    background: var(--surface-2);
    border-radius: 14px;
    padding: 4px;
    border: 1px solid var(--border);
    gap: 2px;
}
.style-picker label {
    position: relative;
    margin: 0 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 13px !important;
}
.style-picker input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.style-picker .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.style-picker .pill svg { width: 14px; height: 14px; }
.style-picker input:checked + .pill {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* =============================================================
   Tag preview stage (live badge preview in the form)
   ============================================================= */
.tag-preview-stage {
    margin-top: 16px;
    padding: 28px 24px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px dashed var(--border-2);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
}
.tag-preview-stage .preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 140px;
}
.tag-preview-stage .preview-col .label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* =============================================================
   Icon suggestion chips (quick-pick Lucide icons in the form)
   ============================================================= */
.icon-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.icon-suggestions .suggestion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 12px;
    font-family: inherit;
}
.icon-suggestions .suggestion:hover,
.icon-suggestions .suggestion.is-active {
    background: var(--primary-soft);
    color: var(--primary-2);
    border-color: rgba(184,148,94,.3);
}
.icon-suggestions .suggestion svg { width: 14px; height: 14px; }

/* =============================================================
   Product editor — gallery, AI panel, variant grid, etc.
   ============================================================= */

/* ---------- Image gallery / drop zone ---------- */
.product-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.product-gallery .gallery-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}
.product-gallery .gallery-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.product-gallery .gallery-item img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.product-gallery .gallery-item .gi-actions {
    position: absolute;
    top: 8px; right: 8px;
    display: flex; gap: 6px;
}
.product-gallery .gallery-item .gi-btn {
    width: 28px; height: 28px;
    border-radius: 8px;
    border: 0;
    background: rgba(255,255,255,.95);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    transition: background var(--transition), color var(--transition);
}
.product-gallery .gallery-item .gi-btn:hover { background: var(--primary); color: #fff; }
.product-gallery .gallery-item .gi-btn.is-danger:hover { background: var(--danger); color: #fff; }
.product-gallery .gallery-item .gi-btn svg { width: 14px; height: 14px; }
.product-gallery .gallery-item.is-primary { outline: 2px solid var(--primary); outline-offset: -2px; }
.product-gallery .gallery-item .gi-primary-badge {
    position: absolute;
    bottom: 8px; left: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dropzone {
    /* IMPORTANT: this is a <label>, which is inline by default. We make
       it a block-level flex column so the icon + headings stack
       correctly inside the dashed border. */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    border: 2px dashed var(--border-2);
    border-radius: 16px;
    padding: 36px 24px;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.dropzone:hover, .dropzone.is-dragging {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-2);
}
.dropzone .dz-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--primary-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 14px 0;
    box-shadow: var(--shadow-sm);
}
.dropzone .dz-icon svg { width: 24px; height: 24px; }
.dropzone h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
}
.dropzone p  { margin: 0; font-size: 13px; line-height: 1.4; }
.dropzone input[type="file"] { display: none; }

/* When the empty-state lives inside the gallery grid it must span the
   entire row (otherwise it gets shoved into a single 150-px column). */
.gallery-empty {
    grid-column: 1 / -1;
    padding: 22px 20px;
    text-align: center;
    color: var(--text-dim);
    border: 1px dashed var(--border-2);
    border-radius: 14px;
    font-size: 13px;
}

/* ---------- AI generation panel ---------- */
.ai-panel {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, var(--surface) 60%);
    position: relative;
}
.ai-panel .ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.ai-panel .ai-head .ai-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--grad-brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(212, 176, 122, .35);
}
.ai-panel .ai-head .ai-icon svg { width: 18px; height: 18px; }
.ai-panel .ai-head h4 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--text);
}
.ai-panel .ai-head .desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.ai-panel .ai-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.ai-panel .ai-options label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 12.5px !important;
    color: var(--text) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    margin: 0 !important;
    font-weight: 500;
}
.ai-panel .ai-options label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-2) !important;
}
.ai-panel .ai-options input[type="checkbox"] { accent-color: var(--primary); }
.ai-panel .ai-options .review-count {
    display: flex; align-items: center; gap: 6px;
    margin-left: auto;
}
.ai-panel .ai-options .review-count input {
    width: 58px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--text);
    text-align: center;
}
.ai-panel .ai-status {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-panel .ai-status svg { width: 14px; height: 14px; flex-shrink: 0; }
.ai-panel .ai-status:not(.is-error) svg { color: var(--success); }
.ai-panel .ai-status.is-error { color: var(--danger); }
.ai-panel .ai-status.is-error svg { color: var(--danger); }
.ai-panel.is-disabled .ai-options label { opacity: .55; pointer-events: none; }
.ai-panel .ai-status .spinner {
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -2px;
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Price + discount group ---------- */
.price-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.input-prefix {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
    transition: border-color var(--transition);
}
.input-prefix:focus-within { border-color: var(--primary); }
.input-prefix .prefix {
    padding: 0 14px;
    background: var(--surface-2);
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    font-weight: 600;
    border-right: 1px solid var(--border);
    font-size: 13px;
}
.input-prefix input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 0 12px;
    height: 42px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: 0;
}
.discount-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px;
}

/* Live price preview pill */
.price-preview {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: 12px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text);
}
.price-preview .was {
    text-decoration: line-through;
    color: var(--text-dim);
}
.price-preview .now {
    color: var(--success);
    font-weight: 700;
}
.price-preview .save {
    background: var(--success-soft);
    color: #46673f;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

/* ---------- Multi-select chip picker (categories, tags, related) ---------- */
.chip-picker {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    padding: 8px;
}
.chip-picker .selected {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    margin-bottom: 8px;
}
.chip-picker .selected:empty::before {
    content: "Nothing selected yet";
    color: var(--text-dim);
    font-size: 12.5px;
    padding: 4px 6px;
}
.chip-picker .selected .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-soft);
    color: var(--primary-2);
    border: 1px solid rgba(184, 148, 94, 0.25);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.chip-picker .selected .chip button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    width: 16px; height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chip-picker .selected .chip button svg { width: 12px; height: 12px; }
.chip-picker .picker-input {
    position: relative;
}
.chip-picker .picker-input input {
    width: 100%;
    border: 0;
    background: var(--surface-2);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    outline: 0;
}
.chip-picker .picker-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
    z-index: 10;
}
.chip-picker .picker-results.is-open { display: block; }
.chip-picker .picker-results .pr-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chip-picker .picker-results .pr-item:hover,
.chip-picker .picker-results .pr-item.is-active { background: var(--primary-soft); color: var(--primary-2); }
.chip-picker .picker-results .pr-empty {
    padding: 12px;
    font-size: 12.5px;
    color: var(--text-dim);
    text-align: center;
}

/* ---------- Variant grid ---------- */
.variant-grid { display: flex; flex-direction: column; gap: 12px; }
.variant-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 200px 200px 40px;
    gap: 12px;
    align-items: start;
}
.variant-card.is-removed { display: none; }
.variant-card .vc-name input { width: 100%; }
.variant-card .vc-images {
    grid-column: 1 / -1;
}
.variant-card .vc-images-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}
.variant-card .vc-images-picker {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.variant-card .vc-image-thumb {
    position: relative;
    width: 64px; height: 64px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    background: var(--surface-2);
    transition: transform var(--transition), border-color var(--transition);
}
.variant-card .vc-image-thumb:hover { transform: translateY(-2px); }
.variant-card .vc-image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.variant-card .vc-image-thumb.is-selected { border-color: var(--primary); }
.variant-card .vc-image-thumb .vc-check {
    position: absolute; top: 4px; right: 4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
}
.variant-card .vc-image-thumb .vc-check svg { width: 12px; height: 12px; }
.variant-card .vc-image-thumb.is-selected .vc-check { display: inline-flex; }
.variant-card .vc-remove {
    border: 0;
    background: var(--danger-soft);
    color: #8d4848;
    border-radius: 10px;
    cursor: pointer;
    width: 40px; height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.variant-card .vc-remove:hover { background: var(--danger); color: #fff; }
.variant-card .vc-no-images {
    color: var(--text-dim);
    font-size: 12.5px;
    padding: 6px 0;
}

/* ---------- Star rating display ---------- */
.stars {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: #d4a44a;
}
.stars svg { width: 14px; height: 14px; }
.stars .empty { color: var(--border-2); }

/* Star picker (input) */
.star-picker {
    display: inline-flex;
    gap: 4px;
    font-size: 26px;
    color: var(--border-2);
    cursor: pointer;
    user-select: none;
}
.star-picker .star.is-on { color: #d4a44a; }
.star-picker .star:hover, .star-picker .star:hover ~ .star {
    /* hover effects handled in JS */
}

/* ---------- Reviews inline list (on product edit page) ---------- */
.review-row {
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    align-items: start;
}
.review-row:last-child { border-bottom: 0; }
.review-row .avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.review-row .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.review-row .body { color: var(--text); margin-top: 6px; font-size: 13.5px; line-height: 1.55; }
.review-row .actions { display: flex; gap: 6px; }

/* ---------- Settings page (key/value editor) ---------- */
.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 18px;
}
.settings-card h3 {
    font-family: var(--font-display);
    font-size: 18px;
    margin: 0 0 4px;
    color: var(--text);
}
.settings-card .sc-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

/* ---------- Compact pages-actions on product list ---------- */
.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}
.product-cell .thumb {
    width: 56px; height: 56px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.product-cell .thumb-placeholder {
    width: 56px; height: 56px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.product-cell .info strong { display: block; color: var(--text); margin-bottom: 2px; }
.product-cell .info .sku   { font-size: 12px; color: var(--text-muted); }

/* =============================================================
   Inventory product picker (single-select, AJAX-searched)
   Used on pages/products/create.php and edit.php to bind a
   storefront product to a row in dbo.Products.
   ============================================================= */
.product-picker {
    position: relative;
    width: 100%;
}
.product-picker .pp-control {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 10px 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.product-picker .pp-control:hover,
.product-picker .pp-control:focus {
    border-color: var(--primary);
    outline: none;
}
.product-picker.is-open .pp-control {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(196, 154, 84, 0.15);
}
.product-picker .pp-display {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}
.product-picker .pp-name {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.product-picker .pp-placeholder { color: var(--text-muted); }
.product-picker .pp-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}
.product-picker .pp-pill.pp-price {
    background: var(--success-soft, #e8f5e9);
    color: var(--success, #2e7d32);
    border-color: transparent;
}
.product-picker .pp-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.product-picker .pp-clear {
    appearance: none;
    border: 0;
    background: var(--surface-2);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background .15s ease, color .15s ease;
}
.product-picker .pp-clear:hover {
    background: var(--danger-soft, #fdecea);
    color: var(--danger);
}
.product-picker .pp-clear svg { width: 14px; height: 14px; }
.product-picker .pp-chev {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform .15s ease;
}
.product-picker.is-open .pp-chev { transform: rotate(180deg); }

.product-picker .pp-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(28, 28, 36, 0.08);
    overflow: hidden;
}
.product-picker .pp-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.product-picker .pp-search svg { width: 14px; height: 14px; color: var(--text-muted); }
.product-picker .pp-search input {
    flex: 1;
    border: 0;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text);
}
.product-picker .pp-results {
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
}
.product-picker .pp-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    appearance: none;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
    transition: background .12s ease;
}
.product-picker .pp-item:hover,
.product-picker .pp-item:focus {
    background: var(--surface-2);
    outline: none;
}
.product-picker .pp-item-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.product-picker .pp-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.product-picker .pp-status {
    padding: 14px 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}
.product-picker .pp-status.pp-error { color: var(--danger); }

/* Required asterisk inside a field label. */
.field label .req { color: var(--danger); margin-left: 2px; }

/* =============================================================
   WordPress importer page
   ============================================================= */
.import-page .desc code,
.import-page code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--text);
}
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.import-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
}
.import-stat .lbl {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.import-stat .val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-top: 4px;
}
.import-stat .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.import-stat .val.is-ok    { color: var(--success); }
.import-stat .val.is-error { color: var(--danger); }

.input-inline {
    display: inline-block;
    width: 60px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    margin: 0 4px;
}

.import-progress { margin-top: 16px; }
.import-progress .ip-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}
.import-progress .ip-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-strong, var(--primary)));
    transition: width .25s ease;
}
.import-progress .ip-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
}
.import-progress .ip-meta.is-error,
.import-progress [data-progress-text].is-error { color: var(--danger); }
.import-progress .ip-counters { display: flex; flex-wrap: wrap; gap: 6px; }

.import-log {
    margin-top: 16px;
    max-height: 320px;
    overflow-y: auto;
    background: #1e1e26;
    color: #d6d6df;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 12.5px;
    border-radius: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
}
.import-log .il-row { padding: 2px 0; white-space: pre; }
.import-log .il-row.is-error { color: #ffb4b4; }

/* =============================================================
   Switch toggle
   ============================================================= */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
    width: 38px; height: 22px;
    background: var(--border-2);
    border-radius: 999px;
    transition: background var(--transition);
    position: relative;
    flex-shrink: 0;
}
.switch .track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}
.switch input:checked + .track { background: var(--grad-brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch .text { font-size: 13px; }

/* =============================================================
   Form grid + form sections (used in create/edit pages)
   ============================================================= */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.form-grid .field-full { grid-column: 1 / -1; }
@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; }
}

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.form-section-header h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}
.form-section-header .desc {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-top: 4px;
}
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 6px;
}
.form-help { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.field-error { color: var(--danger); font-size: 11.5px; margin-top: 6px; }
.field-label-block {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* =============================================================
   Permission matrix (used on Role edit)
   ============================================================= */
.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.perm-group {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.perm-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.perm-group-header h4 {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}
.perm-list { display: flex; flex-direction: column; gap: 8px; }
.perm-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background var(--transition);
    cursor: pointer;
}
.perm-row:hover { background: var(--surface-3); }
.perm-row input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--primary);
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}
.perm-row .perm-info { flex: 1; }
.perm-row .perm-info strong {
    display: block;
    font-size: 13px;
    font-weight: 500;
}
.perm-row .perm-info code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.perm-row .perm-info .perm-desc {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}
.perm-row.is-static { cursor: default; }
.perm-row.is-static:hover { background: transparent; }
.perm-row .perm-icon {
    width: 18px; height: 18px;
    color: var(--primary-2);
    margin-top: 2px;
    flex-shrink: 0;
}

/* checkbox group for assigning roles to a user */
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.check-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface-2);
}
.check-card:hover { border-color: var(--border-2); }
.check-card input { margin-top: 2px; accent-color: var(--primary); cursor: pointer; }
.check-card .label strong { display: block; font-size: 13px; font-weight: 600; }
.check-card .label span { color: var(--text-muted); font-size: 12px; }
.check-card.is-checked {
    background: var(--primary-soft);
    border-color: rgba(184,148,94,.4);
}

/* =============================================================
   Confirm / danger card (used on delete pages)
   ============================================================= */
.confirm-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 560px;
    margin: 0 auto;
}
.confirm-card h2 {
    font-family: var(--font-display);
    font-size: 22px;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}
.confirm-card p { color: var(--text-muted); margin: 0 0 18px; }
.confirm-card .target {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-family: var(--font-mono);
    font-size: 13px;
}

/* =============================================================
   Image uploader / preview
   ============================================================= */
.image-uploader {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 700px) {
    .image-uploader { grid-template-columns: 1fr; }
}
.image-preview {
    width: 180px;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    border: 1px dashed var(--border-2);
    background: var(--surface-2);
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--text-dim);
    position: relative;
}
.image-preview img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.image-preview.is-wide { aspect-ratio: 16 / 9; width: 100%; }
.image-preview .placeholder {
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    font-size: 12px;
}
.image-preview .placeholder svg { width: 24px; height: 24px; }
.image-uploader .controls {
    display: flex; flex-direction: column; gap: 10px;
}
.image-uploader .file-input { display: none; }
.image-uploader .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.image-uploader .url-row {
    display: flex; gap: 8px; align-items: center;
}
.image-uploader .url-row .input { flex: 1; }

/* row of two side-by-side image uploaders (thumb + banner) */
.image-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

/* =============================================================
   Tabs (used on category create/edit)
   ============================================================= */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
    overflow-x: auto;
}
.tabs button {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    padding: 12px 16px;
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: color var(--transition);
}
.tabs button svg { width: 16px; height: 16px; }
.tabs button:hover { color: var(--text); }
.tabs button.is-active { color: var(--primary-2); }
.tabs button.is-active::after {
    content: '';
    position: absolute;
    left: 12px; right: 12px; bottom: -1px;
    height: 2px;
    background: var(--grad-brand);
    border-radius: 2px 2px 0 0;
}
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* =============================================================
   Character counter (under inputs)
   ============================================================= */
.char-counter {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
}
.char-counter.is-over { color: var(--danger); }
.char-counter .hint { color: var(--text-dim); }

/* =============================================================
   SEO preview (Google-style snippet)
   ============================================================= */
.seo-preview {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    margin-top: 12px;
}
.seo-preview .seo-url {
    color: var(--success);
    font-size: 12.5px;
    word-break: break-all;
}
.seo-preview .seo-title {
    font-family: var(--font-display);
    color: #1a0dab;
    font-size: 19px;
    font-weight: 600;
    margin: 4px 0 4px;
    line-height: 1.25;
}
[data-theme="dark"] .seo-preview .seo-title { color: #8ab4f8; }
.seo-preview .seo-desc {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

/* =============================================================
   Detail rows (label / value pairs on view pages)
   ============================================================= */
.detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    align-items: start;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row .label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.detail-row .value { font-size: 13.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "main";
    }
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        width: 270px;
        transform: translateX(-100%);
        transition: transform var(--transition);
    }
    .app.sidebar-open .sidebar { transform: translateX(0); }
    .app.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .35);
        z-index: 25;
    }
    .main { padding: 24px; }
    .install-card, .auth-card { padding: 28px; }
}

/* =============================================================
   Home banner (promo slides) admin
   ============================================================= */

.promo-mode-card {
    padding: 20px 22px;
}
.promo-mode-card__head {
    margin-bottom: 14px;
}
.promo-mode-card__head h3 {
    margin: 0 0 4px;
    font-size: 16px;
}
.promo-mode-card__head p {
    margin: 0;
    font-size: 13px;
}

.mode-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.mode-pill {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.mode-pill:hover {
    border-color: var(--primary-2);
    background: var(--primary-soft);
}
.mode-pill.is-active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 2px var(--primary-soft) inset;
}
.mode-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.mode-pill__title {
    font-weight: 600;
    color: var(--text-strong);
    font-size: 14px;
}
.mode-pill__desc {
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.45;
}

/* Wide image preview used in the slides table */
.thumb--wide {
    width: 200px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: block;
    flex-shrink: 0;
}
.thumb--wide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Large image preview shown inside the edit form */
.slide-preview {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    background: var(--surface-2);
}
.slide-preview img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: cover;
}
.slide-preview__caption {
    padding: 10px 14px;
    font-size: 12.5px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* Confirm-delete shared target image */
.confirm-card .target .thumb--wide {
    width: 100%;
    max-width: 420px;
    height: 140px;
    margin: 0 auto;
}

/* =============================================================
   Orders + Regions admin pages
   ============================================================= */

/* Generic helpers used by the order view page. */
.text-right  { text-align: right; }
.text-center { text-align: center; }

.cell-link { color: inherit; text-decoration: none; }
.cell-link:hover { color: var(--primary-2); }

/* Field with a trailing addon (used for "USD" badge on shipping fee). */
.input-group-addon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .12em;
    color: var(--text-muted);
    text-transform: uppercase;
    pointer-events: none;
}
.field .input-group { position: relative; }
.field .input-group .input { padding-right: 56px; }

/* Stat tile shown above the Orders table. */
.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.stat-card__icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--grad-soft);
    color: var(--primary-2);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__value {
    font-family: var(--font-display, var(--font-sans));
    font-size: 22px;
    font-weight: 600;
    color: var(--text-strong);
    line-height: 1.1;
}
.stat-card__label {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Status pill — colour-coded per status. */
.order-status {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .12em;
    font-weight: 600;
}
.order-status--pending    { background: #fff3d6; color: #8a6700; }
.order-status--processing { background: #e1edff; color: #1d4ea3; }
.order-status--shipped    { background: #e2efe5; color: #196b45; }
.order-status--delivered  { background: #d6f0e0; color: #0f5d34; }
.order-status--cancelled  { background: #fbe1de; color: #962014; }

/* Order detail: two-column layout (items + side meta). */
.order-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 22px;
    align-items: start;
}
.order-aside { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 1024px) {
    .order-grid { grid-template-columns: 1fr; }
}

.card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 14px;
}
.card-head h3 {
    font-size: 15px; font-weight: 600;
    color: var(--text-strong);
    margin: 0;
    letter-spacing: .02em;
}

/* Cleaner table inside cards (no zebra striping, tighter padding). */
.data-table--clean tbody tr:nth-child(even) { background: transparent; }
.data-table--clean th, .data-table--clean td {
    padding: 12px 14px;
}
.data-table--clean tfoot td {
    border-top: 1px solid var(--border);
    background: var(--surface-soft, transparent);
}

/* Line item visual (product + image + variant). */
.order-item {
    display: flex; align-items: center; gap: 12px;
}
.order-item__media {
    width: 60px; height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-soft, #f5efe2);
    flex-shrink: 0;
}
.order-item__media img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.order-item__noimg {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    color: var(--text-muted);
}
.order-item__meta { flex: 1; min-width: 0; }

/* Key-value definition list used in side cards. */
.kv { margin: 0; display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; }
.kv dt { color: var(--text-muted); font-size: 12.5px; }
.kv dd { margin: 0; font-size: 13.5px; color: var(--text-strong); word-break: break-word; }

/* Status form on order view (status select + button). */
.order-status-form .status-current { margin-bottom: 12px; }
.order-status-form label { display: block; margin-bottom: 6px; }
.order-status-form .form-actions { margin-top: 12px; }

/* =============================================================
   CRM Tasks page

   Two-pane workspace:
     LEFT  : scrollable list of open follow-up tasks (.crm-tasks)
     RIGHT : selected client's order history + close form
             (.crm-detail). On small screens we collapse to a
             single column.
   ============================================================= */
.crm-pane {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 960px) {
    .crm-pane { grid-template-columns: 1fr; }
}

/* ---- LEFT: tasks list ---- */
.crm-tasks {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
}
.crm-tasks__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-2);
    font-size: 12.5px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.crm-tasks__empty {
    padding: 36px 22px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.crm-tasks__empty p { margin: 0; }

.crm-task-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}
.crm-task-list li + li { margin-top: 6px; }

.crm-task-card {
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .12s ease;
    display: block;
    color: inherit;
    font: inherit;
}
.crm-task-card:hover {
    background: var(--surface-2);
    border-color: var(--border);
}
.crm-task-card.is-active {
    background: var(--primary-soft);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary) inset;
}
.crm-task-card.is-closed { opacity: .65; }
.crm-task-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.crm-task-card__name {
    font-weight: 600;
    color: var(--text-strong);
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crm-task-card__phone {
    font-size: 13px;
    color: var(--text);
    letter-spacing: .02em;
    margin-bottom: 6px;
}
.crm-task-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11.5px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.crm-task-card__meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.crm-task-card__meta svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* ---- RIGHT: detail panel ---- */
.crm-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 22px;
    min-height: 320px;
}
.crm-detail__placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.crm-detail__placeholder h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-strong);
    font-weight: 600;
}
.crm-detail__placeholder p { margin: 0; font-size: 13.5px; }

.crm-client-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
}
.crm-client-head__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.crm-client-head h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-strong);
}
.crm-client-head .crm-client-meta {
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.crm-client-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.crm-client-meta svg { width: 14px; height: 14px; }

/* WhatsApp deep-link on the client phone. */
.crm-phone-link,
.crm-phone-link:visited {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 12px;
    background: #25D366;                    /* WhatsApp brand green */
    color: #fff !important;
    border: 0;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: .01em;
    line-height: 1;
    text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
    white-space: nowrap;
}
.crm-phone-link:hover {
    background: #1ebc5b;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 211, 102, .35);
}
.crm-phone-link:focus-visible {
    outline: 2px solid #25D366;
    outline-offset: 2px;
}
.crm-phone-link__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #fff;
}
.crm-phone-link__num {
    font-variant-numeric: tabular-nums;
}

.crm-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.crm-orders-table thead th {
    text-align: left;
    padding: 10px 12px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border-soft);
}
.crm-orders-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text);
}
.crm-orders-table tbody tr {
    cursor: pointer;
    transition: background .12s ease;
}
.crm-orders-table tbody tr:hover { background: var(--surface-2); }
.crm-orders-table tbody tr:last-child td { border-bottom: 0; }
.crm-orders-table .text-right { text-align: right; }

.crm-empty-orders {
    padding: 22px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
    background: var(--surface-2);
    border-radius: 10px;
}

/* Close-task form (under the orders table) */
.crm-close-form {
    margin-top: 22px;
    padding: 16px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
}
.crm-close-form__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-strong);
}
.crm-close-form textarea {
    width: 100%;
    min-height: 90px;
    resize: vertical;
}
.crm-close-form .form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.crm-close-form .checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--text-strong);
    user-select: none;
}
.crm-close-form .checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.crm-close-form__status {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    min-height: 18px;
}
.crm-close-form__status.is-success { color: #46673f; }
.crm-close-form__status.is-error   { color: var(--danger); }

/* Field grid used on the new-task modal (label/input pairs side-by-side). */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 600px) {
    .field-grid { grid-template-columns: 1fr; }
}

/* =============================================================
   Modal dialog (used by "New task" + "Order items")
   ============================================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 4vh 16px;
    overflow-y: auto;
}
.modal.is-open { display: flex; }

.modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 16, .45);
    backdrop-filter: blur(2px);
}
.modal__panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
    overflow: hidden;
    animation: modal-pop .18s ease-out;
}
.modal__panel--wide { max-width: 760px; }
@keyframes modal-pop {
    from { transform: translateY(-8px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.modal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-soft);
}
.modal__head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-strong);
}
.modal__close {
    background: transparent;
    border: 0;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.modal__close:hover {
    background: var(--surface-2);
    color: var(--text);
}
.modal__body {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Inside a modal we drive ALL vertical spacing from a single source —
   a stacking column with a fixed gap. This kills the double-margin
   issue caused by .field's own margin-bottom + .field + .field's
   margin-top, which made the 2-column grid row and the single-column
   rows look like they belonged to different layouts. */
.modal__body > .field,
.modal__body > .field-grid,
.modal__body > .alert {
    margin: 0;
}
.modal__body .field-grid > .field { margin: 0; }

.modal__body .form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

/* Order-items popup contents */
.crm-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.crm-items-table th,
.crm-items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
}
.crm-items-table thead th {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}
.crm-items-table tfoot td {
    font-weight: 700;
    color: var(--text-strong);
    border-bottom: 0;
    border-top: 2px solid var(--border);
}
.crm-items-table .text-right { text-align: right; }
.crm-items-table tbody tr:last-child td { border-bottom: 0; }
