/* Flexinfra Projects — "Midnight" theme, matching Flexinfra Sales Focus V50 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy-900: #071326; --navy-800: #0B1B33; --navy-700: #12284A; --navy-600: #1B3863;
  --teal: #14B8A6; --teal-ink: #0F766E; --blue: #2554D9; --blue-ink: #1D44B3;
  --bg: #F3F5F9; --card: #FFFFFF; --line: #E2E7EF; --line-2: #EEF1F6;
  --ink: #0E1A2B; --ink-2: #3B4A61; --muted: #5B6B82;
  --red: #C62828; --red-bg: #FDECEC; --amber: #A15C00; --amber-bg: #FFF4E0; --green: #1B7A3E; --green-bg: #E6F4EA;
  --grey-bg: #EEF1F6;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(14,26,43,.05), 0 4px 16px rgba(14,26,43,.05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #060F1E; --card: #0D1A30; --line: #1E2E4A; --line-2: #16243C;
  --ink: #E8EEF8; --ink-2: #C3CFE2; --muted: #93A3BC;
  --red: #FF8A80; --red-bg: #3A1518; --amber: #FFC266; --amber-bg: #3A2A10; --green: #7DDB9A; --green-bg: #12301E;
  --grey-bg: #16243C; --blue: #5B8CFF; --blue-ink: #8FB0FF;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.num, td.num, .kpi-v { font-variant-numeric: tabular-nums; }
a { color: var(--blue-ink); }
h1, h2, h3 { letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14.5px; font-weight: 700; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); color: #C9D5E8; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 16px; padding: 4px 8px 20px; letter-spacing: -0.01em; }
.brand img { height: 26px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-weight: 800; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #8FA3C2; letter-spacing: .08em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: #C9D5E8; text-decoration: none; font-weight: 500; position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(20,184,166,.14); color: #fff; font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 20px; padding: 1px 8px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { color: #8FA3C2; text-transform: capitalize; }
.side-foot button, .side-foot a { color: #C9D5E8; background: none; border: 0; font: inherit; cursor: pointer; padding: 10px 0; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; margin-right: 14px; }
.side-foot button:hover, .side-foot a:hover { color: #fff; }

main { padding: 28px 32px 60px; max-width: 1360px; width: 100%; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.ph p { margin: 4px 0 0; color: var(--muted); }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-b { padding: 16px 20px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1.4fr 1fr; }
.g2e { grid-template-columns: 1fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* hero */
.hero { background: radial-gradient(120% 140% at 100% 0%, rgba(20,184,166,.35), transparent 50%), linear-gradient(135deg, var(--navy-800), var(--navy-600)); color: #fff; border-radius: var(--radius); padding: 24px 26px; display: grid; grid-template-columns: 1.2fr 2fr; gap: 22px; align-items: center; box-shadow: 0 10px 30px rgba(11,27,51,.25); }
.hero .label { text-transform: uppercase; letter-spacing: .1em; font-size: 11.5px; color: #9FD8D0; font-weight: 700; }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 6px 0; }
.hero .sub { color: #C9D5E8; }
.hero.alarm { background: radial-gradient(120% 140% at 100% 0%, rgba(255,82,82,.4), transparent 55%), linear-gradient(135deg, #3A0D12, var(--navy-800)); }
.hero.alarm .label { color: #FFB4AB; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 12px 14px; }
.kpi-l { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #AFC0DA; font-weight: 600; }
.kpi-v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-s { font-size: 12px; color: #AFC0DA; }
.kpis.light .kpi { background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
.kpis.light .kpi-l, .kpis.light .kpi-s { color: var(--muted); }

/* ---------- health ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 30px; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.h-red { color: var(--red); background: var(--red-bg); }
.h-amber { color: var(--amber); background: var(--amber-bg); }
.h-green { color: var(--green); background: var(--green-bg); }
.h-done, .h-grey { color: var(--muted); background: var(--grey-bg); }
.t-red { color: var(--red); } .t-amber { color: var(--amber); } .t-green { color: var(--green); } .t-muted { color: var(--muted); }

.bar { position: relative; height: 10px; border-radius: 10px; background: var(--grey-bg); overflow: visible; min-width: 120px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 10px; background: linear-gradient(90deg, var(--teal), var(--blue)); }
.bar.red > i { background: linear-gradient(90deg, #E57373, var(--red)); }
.bar.amber > i { background: linear-gradient(90deg, #F0B35A, #D98A00); }
.bar > b { position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px; background: var(--ink); }
.bar-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- lists & tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(37,84,217,.04); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 13px 20px; border-bottom: 1px solid var(--line-2); display: flex; gap: 12px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { color: var(--muted); font-size: 12.5px; }
.empty { padding: 26px 20px; color: var(--muted); text-align: center; }
.reasons { margin: 0; padding-left: 18px; }
.reasons li { margin: 3px 0; }
.code { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.age { font-weight: 800; font-size: 13px; min-width: 44px; text-align: right; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-700); color: #fff; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; }
.journal-text { white-space: pre-wrap; margin: 4px 0 0; }
.journal-next { white-space: pre-wrap; margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; }
.journal-next::before { content: 'Next: '; font-weight: 700; color: var(--muted); }

/* streak strip */
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.day { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--grey-bg); color: var(--muted); }
.day.ok { background: var(--green-bg); color: var(--green); }
.day.miss { background: var(--red-bg); color: var(--red); }
.day.off { opacity: .4; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px var(--font); cursor: pointer; text-decoration: none; box-shadow: 0 1px 1px rgba(14,26,43,.04); }
.btn:hover { border-color: #C5CFDE; }
.btn-primary { background: linear-gradient(180deg, #2E5FE6, var(--blue-ink)); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(37,84,217,.3); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { color: var(--red); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid #C9D2DF; background: var(--card); color: var(--ink); font: 14.5px var(--font); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { border-color: #2B3E5F; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 20px; height: 20px; min-height: 0; }
select.inline { min-height: 36px; padding: 4px 8px; width: auto; font-size: 13px; }
.seg { display: inline-flex; background: var(--grey-bg); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; min-height: 38px; padding: 0 14px; border-radius: 8px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: 600 14px var(--font); color: var(--muted); padding: 0 14px; min-height: 46px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--teal); }
.tabs .count { background: var(--grey-bg); color: var(--ink-2); border-radius: 20px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

/* sheet (modal) */
.sheet-bg { position: fixed; inset: 0; background: rgba(7,19,38,.55); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.sheet { background: var(--card); border-radius: 16px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.sheet .card-h { position: sticky; top: 0; background: var(--card); z-index: 1; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy-800); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.err { background: var(--red); }
.banner { border-radius: 12px; padding: 14px 18px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; font-weight: 600; }
.banner.warn { background: var(--red-bg); color: var(--red); border: 1px solid rgba(198,40,40,.25); }
.banner.ok { background: var(--green-bg); color: var(--green); }
@keyframes fade { from { opacity: 0; } }
.page { animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .page, .sheet-bg { animation: none; } }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(80% 80% at 80% 10%, rgba(20,184,166,.35), transparent 60%), linear-gradient(160deg, var(--navy-800), var(--navy-900)); padding: 16px; }
.login-card { background: #fff; color: #0E1A2B; border-radius: 18px; padding: 32px; width: min(420px, 100%); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.login-card h1 { font-size: 22px; margin: 18px 0 8px; }
.login-card p { color: #5B6B82; }
.login-brand { display: flex; gap: 10px; align-items: center; font-weight: 800; }
.login-card .btn { width: 100%; margin-top: 12px; }
.g-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }

/* ---------- mobile ---------- */
.tabbar { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  main { padding: 18px 14px 96px; }
  .g2, .g2e, .hero { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .row, .row3 { grid-template-columns: 1fr; }
  .hero .big { font-size: 32px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy-800); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: #AFC0DA; text-decoration: none; font-size: 11px; font-weight: 600; }
  .tabbar a.active { color: #fff; box-shadow: inset 0 3px 0 var(--teal); }
  .tabbar svg { width: 20px; height: 20px; }
  .hide-m { display: none; }
  td, th { padding: 10px 10px; }
}
