:root {
    --bg:        #0f172a;
    --surface:   #ffffff;
    --surface-2: #f8fafc;
    --border:    #e2e8f0;
    --text:      #0f172a;
    --muted:     #64748b;
    --primary:   #2563eb;
    --primary-d: #1d4ed8;
    --ok:        #16a34a;
    --ok-bg:     #dcfce7;
    --warn:      #b45309;
    --warn-bg:   #fef3c7;
    --bad:       #dc2626;
    --bad-bg:    #fee2e2;
    --radius:    12px;
    --shadow:    0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .05);
    --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-2);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top bar ---- */
.topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
    flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--primary); color: #fff; font-weight: 700;
}
.topnav { display: flex; gap: 18px; margin-right: auto; }
.topnav a { color: var(--muted); font-weight: 500; }
.topnav a:hover { color: var(--text); text-decoration: none; }
.topuser { display: flex; align-items: center; gap: 12px; }
.who { font-size: .85rem; color: var(--muted); }
.who em { font-style: normal; display: block; font-size: .72rem; color: var(--primary); font-weight: 600; }

/* ---- Layout ---- */
.container { max-width: 1000px; margin: 0 auto; padding: 28px 24px 60px; }
.container.narrow { max-width: 480px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.subtle { color: var(--muted); font-size: .9rem; }

/* ---- Cards ---- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px; margin-bottom: 20px;
}
.card h2 { margin: 0 0 16px; font-size: 1.1rem; }

/* ---- Stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.8rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Forms ---- */
form .field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
input, select, textarea {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
textarea { min-height: 96px; resize: vertical; }
.hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.field-row { display: flex; gap: 16px; }
.field-row > .field { flex: 1; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; border-radius: 8px; transition: background .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: var(--border); color: var(--muted); }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #86efac; }
.flash-error   { background: var(--bad-bg); color: var(--bad); border-color: #fca5a5; }
.flash-info    { background: #dbeafe; color: var(--primary-d); border-color: #93c5fd; }

/* ---- Timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
    content: ""; position: absolute; left: -7px; top: 2px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--primary);
}
.timeline li.done::before { background: var(--primary); }
.timeline li.reject::before { border-color: var(--bad); background: var(--bad); }
.timeline .t-meta { color: var(--muted); font-size: .8rem; }

/* ---- Auth screens ---- */
.auth-wrap { min-height: 70vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .tagline { color: var(--muted); font-size: .9rem; margin: -8px 0 20px; }
.creds { margin-top: 18px; font-size: .8rem; color: var(--muted); background: var(--surface-2); padding: 12px; border-radius: 8px; }
.creds code { color: var(--text); }

/* ---- Hero (landing) ---- */
.hero { text-align: center; padding: 60px 0 30px; }
.hero h1 { font-size: 2.2rem; margin: 0 0 12px; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 560px; margin: 0 auto 24px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 32px; }
.feature { text-align: left; }
.feature h3 { margin: 0 0 6px; font-size: 1rem; }
.feature p { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---- Footer ---- */
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 24px; border-top: 1px solid var(--border); }
.foot-sep { margin: 0 8px; }

.row-actions { display: flex; gap: 8px; }
.doclist { list-style: none; padding: 0; margin: 0; }
.doclist li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.doclist li:last-child { border-bottom: none; }
.dl-grid { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: .92rem; }
.dl-grid dt { color: var(--muted); }
.dl-grid dd { margin: 0; font-weight: 500; }

@media (max-width: 640px) {
    .topbar { gap: 12px; }
    .field-row { flex-direction: column; gap: 0; }
    .who { display: none; }
}
