/* ==========================================================================
   WorkerHub UI
   ========================================================================== */
:root {
    --bg:        #0f1220;
    --sidebar:   #14172a;
    --surface:   #ffffff;
    --surface-2: #f6f7fb;
    --line:      #e7e9f2;
    --ink:       #1a1d2e;
    --ink-soft:  #5b6178;
    --brand:     #5b5bf0;
    --brand-2:   #7c5cff;
    --ok:        #16a34a;
    --warn:      #d97706;
    --bad:       #dc2626;
    --info:      #2563eb;
    --radius:    14px;
    --shadow:    0 10px 30px rgba(20, 23, 42, .08);
    --shadow-sm: 0 2px 8px rgba(20, 23, 42, .06);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--surface-2);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- Layout ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: 250px;
    background: linear-gradient(180deg, #14172a, #191d38);
    color: #c7cbe6;
    display: flex; flex-direction: column;
    padding: 20px 14px;
    z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
.brand-mark {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
}
.brand-mark .ic { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 18px; color: #fff; letter-spacing: .3px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    color: #b9bee0; font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; box-shadow: 0 6px 18px rgba(91, 91, 240, .35);
}
.nav-logout { margin-top: 10px; color: #9aa0c6; }
.nav-logout:hover { background: rgba(220, 38, 38, .15); color: #fecaca; }

.main { margin-left: 250px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 28px; background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 20px; margin: 0; flex: 1; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; display: grid; place-items: center; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 14px; }
.role-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.role-admin   { color: var(--brand); }
.role-manager { color: var(--info); }
.role-worker  { color: var(--ok); }

.content { padding: 28px; max-width: 1200px; width: 100%; }

/* ---------- Hamburger (mobile) ---------- */
.hamburger { display: none; flex-direction: column; gap: 4px; cursor: pointer; }
.hamburger span { width: 22px; height: 2px; background: var(--ink); border-radius: 2px; }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat {
    background: var(--surface); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 6px;
}
.stat .stat-icon {
    width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
    background: var(--surface-2); color: var(--brand); margin-bottom: 6px;
}
.stat .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.stat .stat-label { color: var(--ink-soft); font-size: 13px; }
.stat.accent { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; }
.stat.accent .stat-label { color: rgba(255, 255, 255, .85); }
.stat.accent .stat-icon { background: rgba(255, 255, 255, .18); color: #fff; }

.card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--line); box-shadow: var(--shadow-sm);
    margin-bottom: 24px; overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 16px; margin: 0; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); font-weight: 700; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--ink-soft); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok   { background: #dcfce7; color: #15803d; }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-bad  { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-muted{ background: #eef0f6; color: #64748b; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    font-size: 14px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--ink);
    transition: transform .05s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-success { background: #dcfce7; color: #15803d; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn .ic { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input, .field select, .field textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 91, 240, .15);
}
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Alerts ---------- */
.alert { padding: 13px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: #ecfdf3; color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- Progress bar ---------- */
.progress { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; }

/* ---------- Chart box ---------- */
.chart-box { position: relative; height: 280px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #262a52, transparent), var(--bg); }
.auth-card { background: var(--surface); width: 100%; max-width: 400px; border-radius: 18px; box-shadow: var(--shadow); padding: 34px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card .brand-name { color: var(--ink); }
.auth-sub { text-align: center; color: var(--ink-soft); margin: 0 0 24px; font-size: 14px; }

/* ---------- Misc ---------- */
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.pill-tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.pill-tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.secret { cursor: pointer; user-select: none; }
.secret .reveal { color: var(--brand); font-weight: 600; }
details.reveal-box summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.muted-text { color: var(--ink-soft); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    #nav-toggle:checked ~ .sidebar { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: flex; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
}
