:root {
  --blue:     #007AFF;
  --green:    #34C759;
  --orange:   #FF9500;
  --red:      #FF3B30;
  --purple:   #AF52DE;
  --bg:       #F2F2F7;
  --card:     #FFFFFF;
  --dark:     #1C1C1E;
  --dark2:    #2C2C2E;
  --text:     #000000;
  --text-sec: #636366;
  --text-ter: #AEAEB2;
  --sep:      rgba(60,60,67,0.12);
  --sep-dark: rgba(255,255,255,0.10);
  --fill:     rgba(120,120,128,0.12);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; overflow: hidden; height: 100vh; }

/* ── LOGIN ── */
#login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: #070d07;
  background-image: radial-gradient(ellipse at 25% 30%, rgba(0,122,255,0.07) 0%, transparent 50%),
                    radial-gradient(ellipse at 75% 70%, rgba(52,199,89,0.05) 0%, transparent 50%);
  padding: 24px;
}
.login-wrap { text-align: center; width: 100%; }
.login-eyebrow { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255,255,255,0.25); margin-bottom: 16px; }
.login-title   { font-size: clamp(32px,6vw,52px); font-weight: 800; color: #fff; letter-spacing: -1.5px; line-height: 1; margin-bottom: 8px; }
.login-sub     { font-size: 15px; color: rgba(255,255,255,0.35); margin-bottom: 40px; }
.role-cards    { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 32px; }
.role-card {
  width: 190px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px; padding: 20px 18px; cursor: pointer; text-align: left;
  font-family: var(--font); transition: all 0.2s ease; color: inherit;
}
.role-card:hover { background: rgba(255,255,255,0.09); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,0.35); }
.role-card .rc-icon { font-size: 28px; margin-bottom: 10px; display: block; }
.role-card .rc-name { font-size: 17px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.role-card .rc-sub  { font-size: 12px; color: rgba(255,255,255,0.35); line-height: 16px; }
.login-form {
  display: none; width: 100%; max-width: 340px; margin: 0 auto 24px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 24px 20px;
}
.login-form.visible { display: block; }
.login-form h3 { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 16px; text-align: left; }
.lf-group { margin-bottom: 10px; }
.lf-group label { display: block; font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 5px; }
.lf-group input {
  width: 100%; background: rgba(255,255,255,0.07); border: 1.5px solid transparent;
  border-radius: 10px; padding: 10px 12px; font-family: var(--font); font-size: 16px;
  color: #fff; outline: none; transition: border-color 0.18s;
}
.lf-group input:focus { border-color: var(--blue); }
.lf-group input::placeholder { color: rgba(255,255,255,0.2); }
.login-err { font-size: 13px; color: var(--red); margin-bottom: 10px; text-align: left; display: none; }
.login-err.show { display: block; }
.login-footer { font-size: 11px; color: rgba(255,255,255,0.12); letter-spacing: 0.12em; text-transform: uppercase; }

/* ── APP SHELL ── */
#app-screen { display: none; height: 100vh; flex-direction: column; }
#app-screen.visible { display: flex; }

/* TOPBAR — always fixed at top */
.topbar {
  flex-shrink: 0;
  height: calc(52px + env(safe-area-inset-top));
  background: var(--dark); border-bottom: 1px solid var(--sep-dark);
  display: flex; align-items: flex-end; padding: 0 16px env(safe-area-inset-top, 0); gap: 12px; z-index: 100;
  padding-top: env(safe-area-inset-top);
}
.topbar .tb-menu {
  background: none; border: none; cursor: pointer; padding: 4px 8px 4px 0;
  display: none; flex-direction: column; gap: 4.5px;
}
.topbar .tb-menu span { display: block; width: 18px; height: 1.5px; background: rgba(255,255,255,0.7); border-radius: 1px; }
.topbar .tb-brand { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.5); flex-shrink: 0; }
.topbar .tb-sep   { width: 1px; height: 16px; background: var(--sep-dark); flex-shrink: 0; }
.topbar .tb-title { flex: 1; font-size: 15px; font-weight: 600; color: #fff; }
.topbar .tb-user  { font-size: 12px; color: rgba(255,255,255,0.3); flex-shrink: 0; }

/* BODY = sidebar + content */
.app-body { flex: 1; display: flex; overflow: hidden; }

/* SIDEBAR — fixed, independent scroll */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--dark); border-right: 1px solid var(--sep-dark);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sb-user { padding: 16px 14px 12px; border-bottom: 1px solid var(--sep-dark); }
.sb-user-name { font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.85); }
.sb-user-sub  { font-size: 12px; color: rgba(255,255,255,0.3); margin-top: 2px; }
.sb-nav { flex: 1; padding: 8px 4px; }
.nav-item {
  width: 100%; background: transparent; border: none;
  border-left: 2px solid transparent; border-radius: 0 8px 8px 0;
  padding: 9px 12px; cursor: pointer; display: flex; align-items: center;
  gap: 0; margin-bottom: 1px; font-family: var(--font); transition: background 0.12s;
}
.nav-item:hover { background: rgba(255,255,255,0.04); }
.nav-item.active { background: rgba(255,255,255,0.08); border-left-color: var(--blue); }
.nav-item .ni-label { flex: 1; font-size: 14px; color: rgba(255,255,255,0.45); font-weight: 400; text-align: left; }
.nav-item.active .ni-label { color: #fff; font-weight: 600; }
.nav-badge { background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center; }
.sb-footer { padding: 8px 4px 12px; border-top: 1px solid var(--sep-dark); }
.sb-logout { width: 100%; background: transparent; border: none; color: rgba(255,255,255,0.2); font-size: 13px; cursor: pointer; padding: 8px 12px; border-radius: 8px; text-align: left; font-family: var(--font); }
.sb-logout:hover { color: rgba(255,255,255,0.45); }

/* CONTENT — scrolls independently */
.main-content { flex: 1; overflow-y: auto; }
.content-area { padding: 24px 24px 32px; max-width: 860px; }

/* TAB BAR — mobile bottom, always fixed */
.tab-bar {
  display: none; flex-shrink: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  background: rgba(28,28,30,0.96); border-top: 1px solid var(--sep-dark);
  backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item { flex: 1; background: none; border: none; cursor: pointer; padding: 8px 4px 6px; font-family: var(--font); display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.tab-dot   { width: 4px; height: 4px; border-radius: 2px; }
.tab-label { font-size: 10px; line-height: 13px; text-align: center; }
.tab-badge { position: absolute; top: 4px; right: calc(50% - 14px); background: var(--red); color: #fff; border-radius: 10px; font-size: 9px; font-weight: 700; padding: 1px 4px; min-width: 14px; text-align: center; }

/* SIDEBAR DRAWER — mobile overlay */
.sb-drawer { display: none; position: fixed; inset: 0; z-index: 200; }
.sb-drawer.open { display: flex; }
.sb-drawer-panel { width: 260px; background: var(--dark); height: 100%; overflow-y: auto; display: flex; flex-direction: column; }
.sb-drawer-bg    { flex: 1; background: rgba(0,0,0,0.5); }

/* ── TYPOGRAPHY ── */
.page-title       { margin-bottom: 20px; }
.page-title h1    { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; line-height: 32px; }
.page-title p     { font-size: 14px; color: var(--text-sec); margin-top: 4px; line-height: 20px; }

/* ── METRICS ── */
.metrics { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.metric  { flex: 1; min-width: 120px; border-radius: 14px; padding: 14px 16px; }
.metric .m-val   { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; line-height: 1; margin-bottom: 3px; }
.metric .m-label { font-size: 13px; font-weight: 600; line-height: 18px; }
.metric .m-sub   { font-size: 11px; color: var(--text-ter); margin-top: 2px; }
.metric.white    { background: var(--card); }
.metric.white .m-val, .metric.white .m-label { color: var(--text); }

/* ── CARD / SECTION ── */
.card        { background: var(--card); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--sep); display: flex; align-items: center; justify-content: space-between; }
.card-title  { font-size: 13px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── LIST ROW ── */
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--sep); min-height: 52px; }
.row:last-child { border-bottom: none; }
.row.hl-red    { border-left: 3px solid var(--red); }
.row.hl-orange { border-left: 3px solid var(--orange); }
.row-body      { flex: 1; min-width: 0; }
.row-primary   { font-size: 16px; color: var(--text); line-height: 22px; }
.row-secondary { font-size: 13px; color: var(--text-sec); margin-top: 2px; line-height: 18px; }
.row-right     { flex-shrink: 0; }
.row-action    { flex-shrink: 0; margin-left: 4px; }

/* ── TAGS ── */
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; line-height: 17px; }
.tg  { background: rgba(52,199,89,0.12);  color: #1b7735; }  /* green  */
.tr  { background: rgba(255,59,48,0.12);  color: #c0392b; }  /* red    */
.to  { background: rgba(255,149,0,0.12);  color: #a85e00; }  /* orange */
.tb  { background: rgba(0,122,255,0.12);  color: #005ec4; }  /* blue   */
.tp  { background: rgba(175,82,222,0.12); color: #7b2fa3; }  /* purple */
.tgr { background: rgba(99,99,102,0.10);  color: var(--text-sec); } /* gray */

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: none; border-radius: 10px; padding: 11px 18px; cursor: pointer; font-size: 15px; font-weight: 600; font-family: var(--font); line-height: 1; white-space: nowrap; transition: opacity 0.15s; }
.btn:hover:not(:disabled) { opacity: 0.82; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-sm   { border-radius: 8px; padding: 7px 13px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-p  { background: var(--blue);   color: #fff; }
.btn-g  { background: var(--green);  color: #fff; }
.btn-r  { background: var(--red);    color: #fff; }
.btn-o  { background: var(--orange); color: #fff; }
.btn-t  { background: rgba(0,122,255,0.12); color: var(--blue); }
.btn-n  { background: var(--fill);   color: var(--text-sec); }
.btn-pp { background: #003087;       color: #fff; }

/* ── ALERTS ── */
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; line-height: 20px; }
.al-hl  { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.al-i { background: rgba(0,122,255,0.10);   color: #005ec4; }
.al-w { background: rgba(255,149,0,0.10);   color: #a85e00; }
.al-g { background: rgba(52,199,89,0.10);   color: #1b7735; }
.al-r { background: rgba(255,59,48,0.10);   color: #c0392b; }

/* ── FORM ── */
.f-group { margin-bottom: 12px; }
.f-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; }
.f-field  { width: 100%; font-family: var(--font); font-size: 16px; color: var(--text); outline: none; background: var(--fill); border: 1.5px solid transparent; border-radius: 10px; padding: 10px 12px; line-height: 22px; transition: border-color 0.18s; appearance: none; }
.f-field:focus { border-color: var(--blue); }
.f-field::placeholder { color: var(--text-ter); }
textarea.f-field { resize: vertical; min-height: 80px; }
.f-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 500px; max-height: 92vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.18); }
.modal-hd { padding: 16px 20px; border-bottom: 1px solid var(--sep); display: flex; align-items: center; justify-content: space-between; }
.modal-hd h3 { font-size: 16px; font-weight: 700; }
.modal-x  { width: 28px; height: 28px; border: none; background: var(--fill); border-radius: 50%; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; color: var(--text-sec); }
.modal-bd { padding: 20px; }
.modal-ft { padding: 12px 20px; border-top: 1px solid var(--sep); display: flex; gap: 8px; justify-content: flex-end; }

/* ── PROGRESS ── */
.bar { background: rgba(99,99,102,0.14); border-radius: 3px; height: 5px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.35s ease; }

/* ── TOAST ── */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--dark); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 20px rgba(0,0,0,0.22); max-width: 320px; line-height: 19px; animation: toastIn 0.22s ease; }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--orange); }
@keyframes toastIn { from { transform: translateX(50px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── EMPTY ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-sec); }
.empty-icon { font-size: 44px; margin-bottom: 10px; line-height: 1; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-body  { font-size: 14px; line-height: 20px; max-width: 260px; margin: 0 auto; }

/* ── PRIO CARD ── */
.pcard { background: var(--card); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.pcard.ph { border-left: 3px solid var(--red); }
.pcard.pm { border-left: 3px solid var(--orange); }
.pcard.pn { border-left: 3px solid var(--sep); }
.pcard-body { padding: 14px 16px; }

/* ── MISC ── */
code { font-size: 12px; background: var(--fill); padding: 2px 6px; border-radius: 4px; font-family: 'SF Mono', monospace; }
.flex   { display: flex; }
.fbet   { display: flex; justify-content: space-between; align-items: center; }
.fwrap  { flex-wrap: wrap; }
.gap6   { gap: 6px; }
.gap8   { gap: 8px; }
.gap10  { gap: 10px; }
.mt8    { margin-top: 8px; }
.mt12   { margin-top: 12px; }
.mb12   { margin-bottom: 12px; }
.mb16   { margin-bottom: 16px; }
.w700   { font-weight: 700; }
.w600   { font-weight: 600; }
.fsec   { color: var(--text-sec); }
.fter   { color: var(--text-ter); }
.f14    { font-size: 14px; }
.f13    { font-size: 13px; }
.f12    { font-size: 12px; }

/* ── RESPONSIVE ── */
@media (max-width: 680px) {
  .sidebar { display: none; }
  .topbar .tb-menu { display: flex; }
  .topbar .tb-brand, .topbar .tb-sep { display: none; }
  .tab-bar { display: flex; }
  .content-area { padding: 16px 16px 24px; }
  .metrics .metric { min-width: calc(50% - 5px); }
  .f-row2 { grid-template-columns: 1fr; }
}
