/* FAST Weekly IT Summary — SystemRapid house style */
@import url("https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400&display=swap");

:root {
  --red: #CF212B;
  --red-dark: #A81A22;
  --red-tint: #FBEAEB;
  --ink: #231F20;
  --grey: #6D6E71;
  --grey-light: #A7A9AC;
  --line: #E3E4E6;
  --bg: #F5F5F6;
  --card: #FFFFFF;
  --amber: #B7791F;
  --amber-tint: #FEF5E7;
  --green: #2F855A;
  --green-tint: #EAF6EF;
  --radius: 8px;
  --font: Carlito, Calibri, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 3px solid var(--red);
  position: sticky; top: 0; z-index: 10;
}
.topbar .logo { height: 52px; width: auto; display: block; }
.topbar .title { display: flex; flex-direction: column; }
.topbar .title strong { font-size: 19px; }
.topbar .title span { color: var(--grey); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--grey); font-size: 13px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---------- controls ---------- */
button, .btn {
  font-family: var(--font); font-size: 14px; font-weight: 700;
  border: 1px solid var(--red); background: var(--red); color: #fff;
  padding: 7px 14px; border-radius: 6px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
button.secondary, .btn.secondary { background: #fff; color: var(--red); }
button.secondary:hover { background: var(--red-tint); }
button.ghost { background: transparent; border-color: var(--line); color: var(--grey); font-weight: 400; }
button.ghost:hover { background: var(--bg); }
button:disabled { opacity: .55; cursor: default; }
button.icon { padding: 2px 8px; font-size: 13px; }

input, select, textarea {
  font-family: var(--font); font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red-tint); border-color: var(--red); }
textarea { min-height: 70px; resize: vertical; }
label { font-size: 13px; color: var(--grey); display: block; margin-bottom: 3px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar select { width: auto; }

/* ---------- cards & sections ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 4px; font-size: 18px; color: var(--red);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.card h2 .num {
  display: inline-block; min-width: 26px; text-align: center;
  background: var(--red); color: #fff; border-radius: 4px; font-size: 14px; padding: 1px 6px;
}
.card .src { font-size: 12px; color: var(--grey-light); font-weight: 400; margin-left: auto; }
.card .sub { color: var(--grey); font-size: 13px; margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.empty { color: var(--grey-light); font-style: italic; padding: 6px 0; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  background: var(--red); color: #fff; text-align: left; font-weight: 700;
  padding: 6px 8px; white-space: nowrap;
}
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:nth-child(even) td { background: #FAFAFB; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.edit td { padding: 3px 4px; }
table.edit input, table.edit select { padding: 4px 6px; }

/* ---------- status pills & flags ---------- */
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.pill.red { background: var(--red-tint); color: var(--red); }
.pill.amber { background: var(--amber-tint); color: var(--amber); }
.pill.green { background: var(--green-tint); color: var(--green); }
.pill.grey { background: var(--bg); color: var(--grey); }

.flags { border-left: 5px solid var(--red); }
.flags ul { margin: 0; padding: 0; list-style: none; }
.flags li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.flags li:last-child { border-bottom: 0; }
.flags li .pill { flex: none; min-width: 64px; text-align: center; }
.flags li small { color: var(--grey); display: block; }
.flags.clear { border-left-color: var(--green); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { color: var(--grey); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .delta { font-size: 12px; color: var(--grey); }
.kpi .delta.up { color: var(--red); }
.kpi .delta.down { color: var(--green); }
.kpi svg { display: block; margin-top: 6px; width: 100%; height: 30px; }

/* ---------- sync status bar ---------- */
.syncbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--grey); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: #fff; border-top: 4px solid var(--red); border-radius: var(--radius); padding: 28px; box-shadow: 0 6px 24px rgba(0,0,0,.07); }
.login img { height: 72px; width: auto; max-width: 100%; margin: 0 0 16px -4px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--grey); margin: 0 0 18px; font-size: 14px; }
.login .field { margin-bottom: 12px; }
.login button { width: 100%; justify-content: center; padding: 10px; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 8px; }

.banner { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.banner.info { background: var(--amber-tint); color: #7A5214; }
.banner.ok { background: var(--green-tint); color: var(--green); }

.savebar {
  position: sticky; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  padding: 10px 16px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; z-index: 5;
}
.savebar .msg { margin-right: auto; color: var(--grey); font-size: 13px; }

.print-only { display: none; }
footer.page-foot { text-align: center; color: var(--grey-light); font-size: 12px; padding: 20px; }

@media (max-width: 640px) {
  .topbar { padding: 8px 16px; }
  .topbar .logo { height: 40px; }
  main { padding: 14px 12px 60px; }
  .kpi .value { font-size: 22px; }
}

/* ---------- print / PDF ---------- */
@page {
  size: A4;
  margin: 18mm 12mm 16mm;
  @top-left { content: "FAST Weekly IT Summary"; font-family: Carlito, Calibri, sans-serif; font-size: 9pt; color: #6D6E71; }
  @top-right { content: "SystemRapid"; font-family: Carlito, Calibri, sans-serif; font-size: 9pt; color: #6D6E71; }
  @bottom-left { content: "Confidential — prepared by SystemRapid for FCC / FAST"; font-family: Carlito, Calibri, sans-serif; font-size: 8pt; color: #6D6E71; }
  @bottom-right { content: "Page " counter(page) " of " counter(pages); font-family: Carlito, Calibri, sans-serif; font-size: 9pt; color: #6D6E71; }
}
@media print {
  body { background: #fff; font-size: 11pt; }
  .no-print, .savebar, .toolbar { display: none !important; }
  .print-only { display: block; }
  .topbar { position: static; border-bottom-width: 2px; padding: 0 0 8px; }
  main { max-width: none; padding: 10px 0 0; }
  .card, .kpi { break-inside: avoid; border-color: #ccc; }
  th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pill, .card h2 .num, .flags { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
}

/* Inline SVG charts */
.chart { display: block; width: 100%; height: auto; max-width: 900px; margin: 4px 0 10px; }
.chart rect:hover { opacity: .8; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--grey); margin: 4px 0; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-block { margin-bottom: 8px; }
@media print { .chart { max-width: 100%; break-inside: avoid; } }

/* Section 3: table left, charts right */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.storage-tbl th.c { text-align: center; }
.storage-tbl td, .storage-tbl th { padding: 4px 8px; font-size: 13px; }
.storage-tbl tr.grp-head td { background: var(--bg); font-weight: 700; color: var(--ink); }
.storage-tbl tr.grp-total td { font-weight: 700; border-top: 1px solid var(--grey-light); }
.storage-tbl tr.grand-total td { font-weight: 700; background: var(--red-tint); border-top: 2px solid var(--red); }
@media print { .split { grid-template-columns: 1fr; } }
.storage-tbl .pill { white-space: nowrap; }
