/* WareGo Onboarding — shared design system */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f3f4f6;
    --border: #e5e7eb;
    --border-strong: #d3d8e0;
    --text: #101828;
    --text-2: #475467;
    --muted: #667085;
    --primary: #1d4ed8;
    --primary-hover: #1a41b0;
    --primary-soft: #eef2ff;
    --success: #067647;
    --success-soft: #ecfdf3;
    --warn: #b54708;
    --warn-soft: #fffaeb;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --radius-lg: 12px;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.015em; color: var(--text); }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.125rem; font-weight: 620; }
h3 { font-size: 0.9375rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.fw-bold { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 0.8125rem; }

/* ---------- App shell ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 650;
    color: var(--text);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
}

.brand-sub {
    color: var(--muted);
    font-weight: 450;
    padding-left: 0.625rem;
    margin-left: 0.125rem;
    border-left: 1px solid var(--border);
}

.nav { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }

.nav a {
    color: var(--text-2);
    font-weight: 500;
    font-size: 0.8125rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
}

.nav a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-head p { color: var(--muted); margin-top: 0.25rem; }

/* ---------- Layout helpers ---------- */

.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

@media (max-width: 900px) {
    .grid-3, .grid-2, .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Card ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header p { color: var(--muted); font-size: 0.8125rem; margin-top: 0.125rem; }
.card-body { padding: 1.25rem; }
.card-body.tight { padding: 0.75rem 1.25rem 1.25rem; }
.card-flush { padding: 0; }

/* ---------- Stats ---------- */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.stat-label {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.625rem;
    font-weight: 620;
    letter-spacing: -0.02em;
    margin-top: 0.375rem;
}

.stat-hint { color: var(--muted); font-size: 0.75rem; margin-top: 0.125rem; }

/* ---------- Forms ---------- */

.field { margin-bottom: 1rem; }

.field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 550;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.field .req { color: var(--danger); }
.field-hint { color: var(--muted); font-size: 0.75rem; margin-top: 0.375rem; }

.input, .select, .textarea {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.textarea { resize: vertical; min-height: 60px; }
.select { appearance: none; background-image: none; cursor: pointer; }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.input::placeholder, .textarea::placeholder { color: #98a2b3; }
.field-error { color: var(--danger); font-size: 0.75rem; margin-top: 0.375rem; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5625rem 0.9375rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover { background: var(--primary-hover); }
.btn:disabled { background: #98a2b3; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover { background: var(--surface-3); }
.btn-secondary:disabled { background: var(--surface-3); color: var(--muted); }

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

.btn-success { background: var(--success); }
.btn-success:hover { background: #05603a; }

.btn-danger { background: var(--surface); color: var(--danger); border-color: #f3b5ae; }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { padding: 0.375rem 0.625rem; font-size: 0.75rem; }

/* ---------- Badges / pills ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 550;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge-outline { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: #dbe2fe; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: #abefc6; }
.badge-warning { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdc9; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--surface-2);
    padding: 0.625rem 1.25rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.8125rem;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .cell-actions { white-space: nowrap; text-align: right; }
.table .cell-wrap { max-width: 280px; color: var(--text-2); }
.table-empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* ---------- Key/value + code ---------- */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.375rem 0.875rem; font-size: 0.8125rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

pre.code {
    margin: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--text-2);
    overflow: auto;
    max-height: 340px;
}

details.raw summary {
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 0.625rem;
}

details.raw summary:hover { color: var(--text); }

/* ---------- Overlays: modal, toast, loader ---------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
    display: grid;
    place-items: center;
    padding: 1.5rem;
    z-index: 1000;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.modal-head { padding: 1.25rem 1.25rem 0; }
.modal-body { padding: 0.75rem 1.25rem 1.25rem; color: var(--text-2); font-size: 0.875rem; }

.modal-foot {
    padding: 0.875rem 1.25rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.toast-host {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.75rem 0.9375rem;
    font-size: 0.8125rem;
    color: var(--text);
}

.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warn); }
.toast-danger { border-left-color: var(--danger); }
.toast-title { font-weight: 600; margin-bottom: 0.125rem; }
.toast pre { margin: 0.375rem 0 0; font-size: 0.75rem; color: var(--text-2); white-space: pre-wrap; }

.loader { display: grid; place-items: center; gap: 0.875rem; color: #fff; text-align: center; }

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.spinner-dark { border-color: rgba(16, 24, 40, 0.15); border-top-color: var(--primary); }

@keyframes spin { to { transform: rotate(360deg); } }
