/* =========================================================================
   Spec Desk — design system
   Light, fast, minimal: system-first fonts, flat surfaces, one accent color.
   No JS-driven layout, no heavy assets — everything below is pure CSS so
   first paint is instant.
   ========================================================================= */
:root {
    --mohm-red: #ce1141;
    --mohm-red-deep: #a80d37;
    --mohm-grey: #6b6e73;
    --mohm-dark: #16181c;

    --paper: #f6f6f8;
    --card: #ffffff;
    --ink: #17181a;
    --ink-soft: #6b6e73;
    --ink-faint: #86898f;
    --line: #ebebee;
    --line-strong: #dcdde1;

    --accent: var(--mohm-red);
    --accent-deep: var(--mohm-red-deep);
    --accent-tint: #fdeef1;

    --amber: #a06a1f;
    --amber-tint: #fbf1e0;
    --success: #1e7a4c;
    --success-tint: #e7f6ee;
    --error: var(--mohm-red);
    --error-tint: #fdeef1;

    --sidebar-bg: #15171b;
    --sidebar-bg-soft: #1c1f24;
    --sidebar-ink: #cdd0d4;
    --sidebar-ink-soft: #85898f;
    --sidebar-line: rgba(255,255,255,0.08);

    --font-display: 'Barlow', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Barlow', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;

    --radius: 8px;
    --radius-lg: 14px;
    --shadow-card: 0 1px 2px rgba(20,20,25,0.04), 0 4px 16px rgba(20,20,25,0.04);
    --shadow-pop: 0 8px 28px rgba(20,20,25,0.12);
    --sidebar-w: 240px;
    --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 6px;
}
h1 { font-size: 24px; letter-spacing: -0.01em; font-weight: 700; }
h2 { font-size: 18px; }
h3 { font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); font-weight: 700; margin-bottom: 14px; }

code, .mono { font-family: var(--font-mono); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* ---------------------------------------------------------------------
   App shell — fixed sidebar, independently scrolling content
   --------------------------------------------------------------------- */
.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    padding: 22px 14px 16px;
    overflow-y: auto;
    z-index: 10;
}

.sidebar .brand {
    padding: 2px 8px 20px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--sidebar-line);
}
.sidebar .brand-name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}
.sidebar .brand-sub {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sidebar-ink-soft);
    margin-top: 3px;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--sidebar-ink);
    font-size: 13.5px;
    font-weight: 500;
    transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar nav .icon { width: 16px; text-align: center; opacity: 0.9; font-size: 13px; flex-shrink: 0; }

.sidebar .foot-note {
    margin-top: 18px;
    padding: 12px 10px 0;
    border-top: 1px solid var(--sidebar-line);
    font-size: 11px;
    color: var(--sidebar-ink-soft);
    line-height: 1.5;
}

.sidebar-user {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--sidebar-line);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 10px 4px;
}
.sidebar-user strong { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user a { color: var(--sidebar-ink-soft); font-size: 12px; margin-top: 2px; }
.sidebar-user a:hover { color: #fff; }

.role-badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--sidebar-ink-soft);
    background: rgba(255,255,255,0.08);
    padding: 2px 7px;
    border-radius: 999px;
    margin: 2px 0 4px;
}

.content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    padding: 30px 36px 60px;
    max-width: 1180px;
}

.page-header { margin-bottom: 24px; }
.page-header h1 { margin: 0; }
.subtitle { margin: 5px 0 0; color: var(--ink-soft); font-size: 13.5px; }

.page-body > *:last-child { margin-bottom: 0; }

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        padding: 12px 14px;
    }
    .sidebar .brand { display: none; }
    .sidebar nav { flex-direction: row; }
    .sidebar .foot-note, .sidebar-user { display: none; }
    .shell { flex-direction: column; }
    .content { margin-left: 0; padding: 20px 18px 50px; max-width: 100%; }
}

/* ---------------------------------------------------------------------
   Cards / surfaces
   --------------------------------------------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 22px 24px;
    margin-bottom: 18px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------
   Stats
   --------------------------------------------------------------------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.stat-num { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-label { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 6px; font-weight: 600; }

/* ---------------------------------------------------------------------
   Buttons / forms
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    transition: background-color 140ms var(--ease), transform 140ms var(--ease), box-shadow 140ms var(--ease);
}
.btn:hover { background: var(--accent-deep); text-decoration: none; box-shadow: 0 6px 16px rgba(206,17,65,0.22); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--paper); box-shadow: none; }
.btn.danger { background: var(--error); }
.btn.danger:hover { background: #8f3c2a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.sm { font-size: 12px; padding: 5px 10px; gap: 6px; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 5px; }
label:first-child { margin-top: 0; }

input[type=text], input[type=number], input[type=password], input[type=file], textarea, select {
    width: 100%;
    font-family: var(--font-body);
    font-size: 13.5px;
    padding: 10px 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
textarea { resize: vertical; min-height: 90px; font-family: var(--font-body); }
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(206,17,65,0.1);
}

.field-hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* Dropzone */
.dropzone {
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    padding: 34px 20px;
    text-align: center;
    background: var(--accent-tint);
    color: var(--accent-deep);
    cursor: pointer;
    transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}
.dropzone.dragover { border-color: var(--accent); background: #fbe1e7; }
.dropzone .file-icon { font-size: 30px; margin-bottom: 8px; }
.dropzone strong { display: block; margin-bottom: 3px; }
.dropzone small { color: var(--ink-soft); }
.dropzone .picked-file { margin-top: 12px; font-family: var(--font-mono); font-size: 13px; color: var(--ink); }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); font-weight: 700; }
tr:hover td { background: var(--paper); }
td.mono { font-family: var(--font-mono); font-size: 12px; }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------------
   Swatch chips
   --------------------------------------------------------------------- */
.swatch-list { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 3px 10px 3px 4px;
    font-size: 12px;
    white-space: nowrap;
}
.swatch-chip .dot {
    width: 14px; height: 14px; border-radius: 50%;
    background: linear-gradient(135deg, #cbbfa1, #8d7a5b);
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}
.swatch-chip .label { color: var(--ink-soft); }
.swatch-chip .value { font-family: var(--font-mono); color: var(--ink); }

/* ---------------------------------------------------------------------
   Badges / pills
   --------------------------------------------------------------------- */
.badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 999px;
}
.badge.pending { background: var(--line); color: var(--ink-soft); }
.badge.running, .badge.generating, .badge.writing, .badge.importing, .badge.starting, .badge.estimating { background: var(--amber-tint); color: var(--amber); }
.badge.completed { background: var(--success-tint); color: var(--success); }
.badge.failed { background: var(--error-tint); color: var(--error); }
.badge.admin { background: var(--accent-tint); color: var(--accent-deep); }
.badge.user { background: var(--line); color: var(--ink-soft); }

/* ---------------------------------------------------------------------
   Progress bar
   --------------------------------------------------------------------- */
.progress-track { background: var(--line); border-radius: 999px; height: 9px; overflow: hidden; }
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-deep));
    border-radius: 999px;
    transition: width 300ms var(--ease);
    width: 0%;
}
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-pct { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent-deep); min-width: 40px; text-align: right; }

/* ---------------------------------------------------------------------
   Alerts
   --------------------------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert.success { background: var(--success-tint); color: #175939; border-color: #b9e2cb; }
.alert.error { background: var(--error-tint); color: #8c1836; border-color: #f3bfcb; }
.alert.info { background: var(--accent-tint); color: var(--accent-deep); border-color: #f3c1cd; }

/* ---------------------------------------------------------------------
   Product cards
   --------------------------------------------------------------------- */
.product-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.product-card .thumb {
    height: 150px;
    background: var(--paper) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-faint);
    font-size: 12px;
    border-bottom: 1px solid var(--line);
}
.product-card .body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; }
.product-card .code { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }
.product-card .family-tag { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.product-card .desc { font-size: 12.5px; color: var(--ink-soft); flex: 1; margin: 6px 0 12px; }
.product-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
a.product-card, a.product-card:hover { text-decoration: none; color: inherit; }
.product-card .meta-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-soft); }
.product-card .edit-link { color: var(--accent-deep); font-weight: 600; }

/* ---------------------------------------------------------------------
   Photo preview
   --------------------------------------------------------------------- */
.photo-preview {
    width: 100%;
    max-width: 240px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--paper);
}

.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 11px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    font-size: 13px;
    color: var(--ink);
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state .glyph { font-size: 34px; margin-bottom: 10px; color: var(--ink-faint); }
.empty-state p { margin: 0 0 4px; }
.empty-state .btn { margin-top: 14px; }

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */
.app-footer {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    text-align: center;
    font-size: 11.5px;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    color: var(--ink-faint);
}
