/* Unity Document Solutions — customer portal styles.
   Clean professional light theme on the Unity brand red (#c4232d) with a deep
   plum-ink and a blue accent; green/amber for states. Mobile-first.
   NB: --blue/--navy tokens carry the brand RED so existing markup needs no
   churn; --accent holds the secondary brand blue (info / AI). */
:root {
  --bg-0: #f3edee;
  --bg-1: #faf6f7;
  --ink: #1a1230;
  --muted: #6a6478;
  --faint: #a59fb2;
  --blue: #c4232d;        /* Unity brand red (primary) */
  --blue-2: #d21317;      /* brighter red (gradient end / hover) */
  --blue-deep: #9e1b23;   /* deep red */
  --navy: #1a1230;        /* plum-ink (secondary) */
  --accent: #1265a2;      /* Unity secondary blue (info / AI) */
  --card: #ffffff;
  --card-2: #f6f1f2;
  --line: #ece5e7;
  --line-2: #ddd2d5;
  --green: #16a34a;
  --amber: #d97706;
  --red: #c4232d;
  --radius: 14px;
  --shadow: 0 16px 44px rgba(26, 18, 48, 0.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(780px 460px at 84% -10%, rgba(196, 35, 45, 0.10), transparent 60%),
    radial-gradient(720px 460px at -6% 4%, rgba(26, 18, 48, 0.06), transparent 55%),
    linear-gradient(170deg, var(--bg-1), var(--bg-0) 70%) fixed;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 18px 16px 60px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mt { margin-top: 8px; }
.err-text { color: var(--red); }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }

/* ---- brand mark ---- */
.mark {
  font-weight: 900; letter-spacing: -0.02em;
  color: var(--blue);
}
.mark .x { color: var(--navy); }
.mark.sm { font-size: 18px; }

/* ---- auth ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; padding: 30px;
  box-shadow: var(--shadow);
}
.auth-card .brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-card .mark { font-size: 26px; }
.brand-name { font-weight: 900; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.or { text-align: center; color: var(--faint); font-size: 12.5px; margin: 16px 0 12px; }

/* ---- header / nav ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 900; text-decoration: none; color: var(--ink); }
.logo-name { font-size: 15px; color: var(--muted); font-weight: 700; }
@media (max-width: 560px) { .logo-name { display: none; } }
.topbar nav { margin-left: auto; display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.topbar nav button {
  position: relative; background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 13.5px; padding: 8px 11px;
  border-radius: 9px; cursor: pointer;
}
.topbar nav button.active { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-2)); }
.topbar nav button:not(.active):hover { color: var(--ink); background: var(--card-2); }
#logout-btn { font-size: 16px; }
.dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

/* ---- cards / layout ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15, 28, 51, 0.04);
}
.card.glow { box-shadow: 0 0 0 1px rgba(196, 35, 45, 0.16), 0 12px 30px rgba(196, 35, 45, 0.08); }
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card h2.spaced { margin-bottom: 14px; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 22px 2px 12px; }
.section-head h1 { font-size: 22px; }
.section-head p { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }
.grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---- stat tiles ---- */
.stat { padding: 16px; }
.stat .num { font-size: 26px; font-weight: 900; color: var(--blue); line-height: 1.1; }
.stat .num.blue { color: var(--accent); }
.stat .num.green { color: var(--green); }
.stat .num.amber { color: var(--amber); }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 5px; }

/* ---- rows / lists ---- */
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row .title { font-weight: 700; font-size: 14px; }
.row .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.empty { color: var(--faint); font-size: 13px; padding: 14px 0; text-align: center; }
.money { font-weight: 800; }

/* ---- chips / badges ---- */
.chip {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
}
.chip.green, .chip.done, .chip.completed, .chip.paid, .chip.live, .chip.active, .chip.resolved, .chip.closed { color: var(--green); border-color: rgba(22,163,74,.35); background: rgba(22,163,74,.10); }
.chip.amber, .chip.in_progress, .chip.scheduled, .chip.waiting, .chip.due, .chip.warning, .chip.onboarding, .chip.testing, .chip.scoping, .chip.toner { color: var(--amber); border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.10); }
.chip.red, .chip.action_needed, .chip.overdue, .chip.critical, .chip.high, .chip.open, .chip.on_hold, .chip.repair { color: var(--red); border-color: rgba(220,38,38,.35); background: rgba(220,38,38,.10); }
.chip.blue, .chip.info, .chip.normal, .chip.review, .chip.service, .chip.firmware, .chip.install, .chip.audit { color: var(--accent); border-color: rgba(18,101,162,.35); background: rgba(18,101,162,.10); }
.chip.tier { color: var(--navy); border-color: rgba(26,18,48,.25); background: rgba(26,18,48,.06); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: #fff;
  border: none; font: inherit; font-weight: 800; font-size: 14px;
  padding: 11px 18px; border-radius: 11px; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 13px; font-size: 13px; border-radius: 9px; }
.btn.secondary { background: var(--card-2); color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost { background: #fff; color: var(--blue); border: 1px solid var(--line-2); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid rgba(220,38,38,.35); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---- forms ---- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; background: #fff; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 13px;
  font: inherit; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(196,35,45,.14); }
textarea { resize: vertical; min-height: 90px; }

/* ---- progress ---- */
.bar { height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--navy)); }

/* ---- security score ring ---- */
.score-ring { display: flex; align-items: center; gap: 18px; }
.ring { --v: 0; width: 96px; height: 96px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--blue) calc(var(--v) * 1%), var(--card-2) 0);
  display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--card); }
.ring b { position: relative; font-size: 24px; font-weight: 900; color: var(--ink); }
.ring b small { font-size: 12px; color: var(--muted); font-weight: 700; }

/* ---- timeline ---- */
.timeline { list-style: none; margin-top: 10px; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line-2); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 3px rgba(196,35,45,.16); }
.timeline .t { font-size: 13.5px; }
.timeline .d { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* ---- chat (Ask Us) ---- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 86%; padding: 12px 15px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.bubble.you { align-self: flex-end; background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--card-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble .who { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin-bottom: 4px; }
.ask-bar { display: flex; gap: 10px; align-items: flex-end; margin-top: 14px; }
.ask-bar textarea { min-height: 48px; max-height: 160px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.suggest button { background: var(--card-2); border: 1px solid var(--line-2); color: var(--muted); font: inherit; font-size: 12.5px; padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.suggest button:hover { color: var(--ink); border-color: var(--blue); }
.typing { color: var(--muted); font-size: 13px; font-style: italic; }

/* ---- service cards ---- */
.svc { display: flex; flex-direction: column; height: 100%; }
.svc .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; background: var(--card-2); border: 1px solid var(--line); margin-bottom: 10px; }
.svc h3 { font-size: 15px; }
.svc .cat { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--blue); margin-top: 4px; }
.svc p { color: var(--muted); font-size: 13px; margin-top: 6px; flex: 1; }
.svc .foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }

/* ---- fleet device cards ---- */
.dev { display: flex; flex-direction: column; height: 100%; }
.dev.attn { box-shadow: 0 0 0 1px rgba(217,119,6,.30), 0 10px 26px rgba(217,119,6,.08); }
.dev-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; background: var(--card-2); border: 1px solid var(--line); flex: none; }
.dev-meta { font-size: 12.5px; color: var(--muted); }
.meter { display: flex; gap: 18px; margin: 12px 0 4px; }
.meter .mnum { font-size: 19px; font-weight: 900; color: var(--ink); display: block; line-height: 1.1; }
.meter .mlbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.toners { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.toner-row { display: flex; align-items: center; gap: 8px; }
.toner-lbl { font-size: 11.5px; font-weight: 700; color: var(--muted); width: 46px; flex: none; }
.toner { flex: 1; height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.toner > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.toner.low > span { background: var(--amber); }
.toner-pct { font-size: 11.5px; font-weight: 800; color: var(--muted); width: 34px; text-align: right; flex: none; }
.reading-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-2); }

/* ---- usage by department ---- */
.usage-row { display: flex; align-items: center; gap: 12px; padding-top: 12px; }
.usage-name { font-weight: 700; font-size: 13.5px; width: 130px; flex: none; }
.usage-bar { flex: 1; height: 9px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.usage-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--blue-2)); }
.usage-val { font-size: 13px; font-weight: 800; width: 96px; text-align: right; flex: none; }
.usage-sub { font-size: 11.5px; color: var(--muted); margin: 3px 0 4px 142px; }
@media (max-width: 560px) { .usage-name { width: 96px; } .usage-sub { margin-left: 0; } }

/* ---- engineer visit booking ---- */
.book-slot:empty { display: none; }
.slot-picker { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.slot-grid button {
  background: #fff; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 8px; font: inherit; font-size: 12.5px; font-weight: 800; color: var(--ink);
  cursor: pointer; text-align: center;
}
.slot-grid button span { display: block; font-weight: 600; color: var(--muted); font-size: 11px; margin-top: 2px; }
.slot-grid button:hover { border-color: var(--blue); color: var(--blue); }

/* ---- insights charts ---- */
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart .ax { fill: var(--muted); font-size: 12px; font-weight: 600; }
.chart .val { fill: var(--ink); font-size: 11px; font-weight: 800; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend .sw + .sw, .legend .sw:not(:first-child) { margin-left: 10px; }
.legend .sw.red { background: var(--blue); }
.legend .sw.blue { background: var(--accent); }
.delta { font-weight: 900; }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  padding: 12px 18px; border-radius: 11px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 100; box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); border-color: var(--red); }

/* ---- demo banner ---- */
#demo-banner { background: linear-gradient(90deg, rgba(196,35,45,.12), rgba(26,18,48,.10)); color: var(--ink); font-size: 13px; padding: 9px 16px; text-align: center; border-bottom: 1px solid var(--line); }
#demo-banner a { font-weight: 700; }

/* ---- misc ---- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; text-align: right; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: none; }
.sev { width: 8px; align-self: stretch; border-radius: 4px; flex: none; }
.sev.critical { background: var(--red); }
.sev.warning { background: var(--amber); }
.sev.info { background: var(--accent); }

/* ---- auth extras ---- */
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; font-weight: 700; }
.auth-links a { color: var(--muted); text-decoration: none; }
.auth-links a:hover { color: var(--blue); }
.auth-card h2 { font-size: 16px; }

/* ---- data tables (admin + fleet) ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--card-2); }
.tbl .name { font-weight: 700; }
.tbl-wrap { overflow-x: auto; }

/* ---- health pills ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.pill.healthy { color: var(--green); background: rgba(22,163,74,.10); } .pill.healthy::before { background: var(--green); }
.pill.warning { color: var(--amber); background: rgba(217,119,6,.10); } .pill.warning::before { background: var(--amber); }
.pill.critical { color: var(--red); background: rgba(220,38,38,.10); } .pill.critical::before { background: var(--red); }

/* ---- admin action panels ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 14px; }
.tabs button { background: var(--card-2); border: 1px solid var(--line); color: var(--muted); font: inherit; font-weight: 700; font-size: 13px; padding: 8px 13px; border-radius: 9px; cursor: pointer; }
.tabs button.active { background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: #fff; border-color: transparent; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; background: none; border: none; padding: 0; margin-bottom: 10px; }
.crumb:hover { color: var(--ink); }
.inline-form { display: grid; gap: 10px; }
.inline-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .inline-form .two { grid-template-columns: 1fr; } }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.check-row input { width: auto; }
.notif-row { font-size: 12.5px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.notif-row:last-child { border-bottom: none; }
.notif-row b { color: var(--ink); font-weight: 700; }
