/* ═══════════════════════════════════════════════════════════════════════
   Replaroo — design system
   ───────────────────────────────────────────────────────────────────────
   Fresh, calm, high-contrast. Indigo carries the brand, teal carries "good
   news", and everything else is a warm-cool neutral so the colour that does
   appear actually means something.

   Every colour is a token on :root and re-declared under [data-theme] so the
   whole app flips to dark without a single component knowing about it.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    /* brand */
    --brand-50:  #EEF0FF;
    --brand-100: #E0E3FF;
    --brand-200: #C7CBFE;
    --brand-300: #A5A9FB;
    --brand-400: #8386F6;
    --brand-500: #6366F1;
    --brand-600: #4F46E5;
    --brand-700: #4338CA;
    --brand-800: #3730A3;
    --brand: var(--brand-600);
    --brand-soft: var(--brand-50);
    --brand-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --brand-glow: 0 8px 24px -6px rgba(99, 102, 241, .45);

    /* meaning */
    --teal:    #14B8A6;
    --teal-soft: #E6FBF8;
    --green:   #10B981;
    --green-soft: #E7F8F1;
    --amber:   #F59E0B;
    --amber-soft: #FEF4E4;
    --red:     #EF4444;
    --red-soft: #FEECEC;
    --pink:    #EC4899;
    --violet:  #8B5CF6;

    /* surfaces */
    --bg:        #F7F8FC;
    --surface:   #FFFFFF;
    --surface-2: #FBFBFE;
    --surface-3: #F2F4F9;
    --overlay:   rgba(16, 18, 32, .45);

    /* ink */
    --ink:       #171A26;
    --ink-2:     #3D4356;
    --muted:     #6C7386;
    --faint:     #9AA1B4;

    /* lines */
    --line:      #E7E9F2;
    --line-2:    #DDE0EC;

    /* shape */
    --r-xs: 6px;
    --r-sm: 9px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-full: 999px;

    /* depth */
    --shadow-xs: 0 1px 2px rgba(20, 22, 45, .05);
    --shadow-sm: 0 1px 3px rgba(20, 22, 45, .07), 0 1px 2px rgba(20, 22, 45, .04);
    --shadow-md: 0 4px 14px -3px rgba(20, 22, 45, .10), 0 2px 5px -2px rgba(20, 22, 45, .05);
    --shadow-lg: 0 14px 38px -10px rgba(20, 22, 45, .18), 0 4px 12px -4px rgba(20, 22, 45, .07);
    --shadow-xl: 0 28px 60px -16px rgba(20, 22, 45, .24);

    /* motion */
    --fast: 120ms cubic-bezier(.4, 0, .2, 1);
    --base: 200ms cubic-bezier(.4, 0, .2, 1);
    --slow: 320ms cubic-bezier(.32, .72, 0, 1);

    /* layout */
    --rail: 68px;
    --list-w: 348px;
    --panel-w: 320px;
    --topbar: 56px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    --bg:        #0E1017;
    --surface:   #161926;
    --surface-2: #1B1F2E;
    --surface-3: #222739;
    --overlay:   rgba(0, 0, 0, .6);

    --ink:       #ECEEF6;
    --ink-2:     #C3C8D8;
    --muted:     #8D95AC;
    --faint:     #666E86;

    --line:      #262B3D;
    --line-2:    #323950;

    --brand-soft: #1E2140;
    --teal-soft:  #10312F;
    --green-soft: #10312A;
    --amber-soft: #35270F;
    --red-soft:   #3A1D1F;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 14px -3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 14px 38px -10px rgba(0, 0, 0, .6);
    --shadow-xl: 0 28px 60px -16px rgba(0, 0, 0, .7);
}

/* ── reset ───────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body { overscroll-behavior-y: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.018em; line-height: 1.25; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p  { margin: 0 0 12px; }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; vertical-align: middle; }
[hidden] { display: none !important; }

::selection { background: var(--brand-200); color: var(--ink); }

/* scrollbars that do not shout */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--line-2); border-radius: var(--r-full);
    border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

/* ── typography helpers ──────────────────────────────────────────── */

.muted   { color: var(--muted); }
.faint   { color: var(--faint); }
.small   { font-size: 12.5px; }
.tiny    { font-size: 11.5px; }
.strong  { font-weight: 600; }
.mono    { font-family: var(--mono); font-size: 12.5px; }
.center  { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.eyebrow {
    font-size: 11px; font-weight: 650; letter-spacing: .09em;
    text-transform: uppercase; color: var(--faint);
}

/* ── buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 15px;
    font: inherit; font-weight: 570; font-size: 13.5px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: var(--surface-3); color: var(--ink);
    cursor: pointer; white-space: nowrap;
    transition: background var(--fast), border-color var(--fast),
                transform var(--fast), box-shadow var(--fast), color var(--fast);
    -webkit-user-select: none; user-select: none;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }

.btn-primary {
    background: var(--brand); color: #fff;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .3);
}
.btn-primary:hover { background: var(--brand-700); box-shadow: var(--brand-glow); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); }

.btn-outline { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-outline:hover { background: var(--surface-3); border-color: var(--faint); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #DC2626; }

.btn-soft-danger { background: var(--red-soft); color: var(--red); }
.btn-soft-danger:hover { background: #FDDCDC; }

.btn-sm  { padding: 6px 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg  { padding: 12px 22px; font-size: 15px; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 34px; height: 34px; border-radius: var(--r-sm); }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 5px; }

/* ── forms ───────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

label, .label {
    display: block; margin-bottom: 6px;
    font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.hint { margin-top: 5px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.hint-error { color: var(--red); }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=search], input[type=tel], select, textarea {
    width: 100%; padding: 9px 12px;
    font: inherit; font-size: 14px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
    appearance: none;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }

input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 3.5px var(--brand-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[disabled], select[disabled], textarea[disabled] {
    background: var(--surface-3); color: var(--muted); cursor: not-allowed;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236C7386' d='M6 8 0 1.4 1.4 0 6 4.6 10.6 0 12 1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 34px;
}

input[type=color] {
    width: 44px; height: 36px; padding: 3px; cursor: pointer;
    border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface);
}

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    position: relative; flex: none; width: 38px; height: 22px;
    background: var(--line-2); border-radius: var(--r-full);
    transition: background var(--base);
}
.switch-track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; background: #fff; border-radius: 50%;
    box-shadow: var(--shadow-sm); transition: transform var(--base);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3.5px var(--brand-soft); }
.switch-label { font-size: 13.5px; font-weight: 500; color: var(--ink); }

/* checkbox */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 3px 0; }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.check span { font-size: 13.5px; color: var(--ink); font-weight: 500; }

/* ── cards & surfaces ────────────────────────────────────────────── */

.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: 20px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-body { padding: 20px; }
.card-foot {
    padding: 14px 20px; border-top: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ── badges, pills, avatars ──────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2.5px 8px; border-radius: var(--r-full);
    font-size: 11.5px; font-weight: 600; line-height: 1.6;
    background: var(--surface-3); color: var(--ink-2);
}
.badge-brand { background: var(--brand-soft); color: var(--brand-700); }
.badge-green { background: var(--green-soft); color: #047857; }
.badge-amber { background: var(--amber-soft); color: #B45309; }
.badge-red   { background: var(--red-soft);   color: #B91C1C; }
.badge-teal  { background: var(--teal-soft);  color: #0F766E; }
[data-theme="dark"] .badge-green { color: #34D399; }
[data-theme="dark"] .badge-amber { color: #FBBF24; }
[data-theme="dark"] .badge-red   { color: #F87171; }
[data-theme="dark"] .badge-teal  { color: #2DD4BF; }
[data-theme="dark"] .badge-brand { color: var(--brand-300); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.dot-online { background: var(--green); box-shadow: 0 0 0 2.5px var(--green-soft); }
.dot-busy   { background: var(--amber); box-shadow: 0 0 0 2.5px var(--amber-soft); }
.dot-offline{ background: var(--faint); }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: none;
    border-radius: var(--r-full);
    background: var(--brand-gradient); color: #fff;
    font-size: 12px; font-weight: 650; letter-spacing: .02em;
    overflow: hidden; -webkit-user-select: none; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 68px; height: 68px; font-size: 22px; }

/* Store chips get their own colour, which is how five shops stay apart
   at a glance in a shared inbox. */
.store-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 8px 2px 3px; border-radius: var(--r-full);
    font-size: 11.5px; font-weight: 600;
    background: var(--surface-3); color: var(--ink-2);
    max-width: 150px;
}
.store-chip .swatch {
    width: 16px; height: 16px; border-radius: var(--r-full); flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 700; color: #fff;
}

/* ── empty states ────────────────────────────────────────────────── */

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 56px 28px; text-align: center; color: var(--muted);
    height: 100%;
}
.empty-art {
    width: 62px; height: 62px; margin-bottom: 16px; border-radius: var(--r-xl);
    display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand);
}
.empty h3 { margin-bottom: 6px; color: var(--ink); }
.empty p { max-width: 330px; font-size: 13.5px; line-height: 1.6; }

/* ── toast ───────────────────────────────────────────────────────── */

#toasts {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    z-index: 900; display: flex; flex-direction: column; gap: 8px;
    align-items: center; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 16px; border-radius: var(--r-full);
    background: #171A26; color: #fff;
    font-size: 13.5px; font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in var(--slow) both;
    pointer-events: auto; max-width: min(92vw, 460px);
}
.toast-error { background: var(--red); }
.toast-good  { background: #0F766E; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(14px) scale(.96); }
    to   { opacity: 1; transform: none; }
}
.toast.out { animation: toast-out var(--base) both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ── modal ───────────────────────────────────────────────────────── */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 800;
    background: var(--overlay); backdrop-filter: blur(3px);
    display: grid; place-items: center; padding: 20px;
    animation: fade-in var(--base) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
    background: var(--surface); border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl);
    animation: modal-in var(--slow) both;
}
.modal-lg { max-width: 720px; }
@keyframes modal-in {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: none; }
}
.modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 22px 24px 6px;
}
.modal-body { padding: 12px 24px 22px; }
.modal-foot {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 16px 24px; border-top: 1px solid var(--line);
    background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl);
    position: sticky; bottom: 0;
}

/* ── skeleton loading ────────────────────────────────────────────── */

.skeleton {
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 37%, var(--surface-3) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
    border-radius: var(--r-xs);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
