/* ============================================================================
   MXTG portal — the same design as the desktop software, in CSS.

   The colours below are not invented: they are the Flet app's palette
   (`app.py`, "reference dashboard image — SAME TO SAME", pixel-measured from
   the user's own mockup), kept in the same order and with the same names so
   the two can be compared line by line. If the desktop changes a token, this
   file changes with it.

   The desktop is drawn in a frameless window with a dark rounded bezel; the
   web has no window, so `.frame` plays that part: the bezel is the border of
   the app, the rail is the left column, the panel is the light canvas.
   ========================================================================== */
:root {
  --BG: #c8d9ec;          /* window body (bottom of the gradient)   */
  --BG-TOP: #cddef1;      /* top of the gradient                    */
  --FRAME: #383838;       /* sidebar + dark card + bezel            */
  --FRAME-DK: #242424;    /* logo tile / icon circle                */
  --PANEL: #f6f6f6;       /* content panel (cards sit on this)      */
  --CARD: #ffffff;
  --CARD2: #f2f2f2;
  --SOFT-BG: #e9e9e9;     /* chip / segment / search fill           */
  --BORDER: #e9e9e9;
  --INK: #1f1f1f;
  --MUTED: #8a8f98;
  --SOFT: #b9bec6;
  --PRIMARY: #8ab7ee;
  --PRIMARY-HOVER: #a6c9f2;
  --SEL-INK: #1f1f1f;
  --DANGER: #c0392b;
  --SUCCESS: #4e8c4a;
  --PILL-OK: #dbefc9;
  --PILL-BAD: #fbd5d5;
  --PILL-MID: #ededed;
  --ROW: #f7f7f7;
  --WARN: #b45309;
  --WARN-BG: #fef3c7;
  --WARN-INK: #7c4a03;
  --RAIL-ICON: #8f8f8f;
  --SHADOW: 0 10px 30px rgba(31, 31, 31, 0.06);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: linear-gradient(180deg, var(--BG-TOP) 0%, var(--BG) 100%);
  color: var(--INK);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }

/* `hidden` has to win over every `display:` below it, or a screen meant to be
   gone is merely invisible to the DOM and still painted — which is exactly how
   the sign-in card ended up stacked above the console it had just opened. */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- icons --- */
/* Every icon is inline SVG (`.i`), stroked in `currentColor` so a parent's
   `color` drives it — the same way Flet's icon colour works. */
.i {
  width: 20px; height: 20px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i.sm { width: 16px; height: 16px; }
.i.xs { width: 14px; height: 14px; }
.i.lg { width: 24px; height: 24px; }

/* =========================================================== login screen == */
.login {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--CARD);
  border-radius: 22px;
  padding: 30px 28px 26px;
  box-shadow: 0 24px 60px rgba(31, 31, 31, 0.16);
}

.login-logo {
  width: 84px; height: 84px;
  display: block;
  margin: 0 auto 4px;
  border-radius: 50%;
}

.login h1 {
  margin: 10px 0 2px;
  font-size: 21px;
  text-align: center;
  letter-spacing: 0.3px;
}

.login .sub {
  margin: 0 0 22px;
  text-align: center;
  color: var(--MUTED);
  font-size: 12px;
}

.field { margin-bottom: 13px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--MUTED);
  margin: 0 0 5px 4px;
  letter-spacing: 0.2px;
}

.input {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--BORDER);
  background: var(--SOFT-BG);
  padding: 0 14px;
  outline: none;
  transition: border-color .12s, background .12s;
}

.input:focus {
  background: #fff;
  border-color: var(--PRIMARY);
}

.input::placeholder { color: var(--SOFT); }

select.input { padding-right: 8px; }

.btn {
  height: 46px;
  border-radius: 26px;
  padding: 0 20px;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--SOFT-BG);
  color: var(--INK);
  transition: background .12s, opacity .12s;
  white-space: nowrap;
}

.btn:hover { background: #dedede; }
.btn.primary { background: var(--PRIMARY); }
.btn.primary:hover { background: var(--PRIMARY-HOVER); }
.btn.dark { background: var(--FRAME); color: #fff; }
.btn.dark:hover { background: #4a4a4a; }
.btn.danger { background: var(--PILL-BAD); color: var(--DANGER); }
.btn.wide { width: 100%; }
.btn.sm { height: 34px; font-size: 12px; padding: 0 14px; border-radius: 17px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.login .btn.primary { margin-top: 6px; }

.login-note {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  display: none;
}

.login-note.err { display: block; background: var(--PILL-BAD); color: var(--DANGER); }
.login-note.ok { display: block; background: var(--PILL-OK); color: var(--SUCCESS); }

.login-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--BORDER);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--MUTED);
  font-size: 11px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--SOFT); flex: 0 0 auto; }
.dot.ok { background: var(--SUCCESS); }
.dot.bad { background: var(--DANGER); }
.dot.warn { background: #e0a32e; }

/* ============================================================ app frame === */
.shell {
  height: 100%;
  padding: 14px;
  display: flex;
}

.frame {
  flex: 1;
  min-width: 0;
  display: flex;
  background: var(--FRAME);
  border-radius: 28px;
  padding: 12px;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(31, 31, 31, 0.22);
}

/* ----------------------------------------------------------------- rail --- */
.rail {
  width: 72px;
  flex: 0 0 72px;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rail-logo {
  width: 32px; height: 32px;
  border-radius: 50%;
  margin-bottom: 14px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.rail-item {
  width: 48px; height: 48px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--RAIL-ICON);
  transition: background .12s, color .12s;
}

.rail-item:hover { background: #4a4a4a; color: #fff; }
.rail-item.on { background: #4a4a4a; color: #fff; }
.rail-item.out { color: #fff; }
.rail-item.out:hover { background: var(--DANGER); }

.rail-sep { flex: 1; }

/* ----------------------------------------------------------------- panel -- */
.panel {
  flex: 1;
  min-width: 0;
  background: var(--PANEL);
  border-radius: 20px;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 6px;
}

.greet { display: flex; align-items: center; gap: 12px; min-width: 0; }
.greet .av {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--SOFT-BG);
  color: var(--MUTED);
  font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
  position: relative;
  flex: 0 0 auto;
}
.greet .av .st {
  position: absolute; right: 0; bottom: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--DANGER);
  border: 2px solid var(--PANEL);
}
.greet .g1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.greet .g2 { font-size: 11px; color: var(--MUTED); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.clock {
  flex: 1;
  min-width: 0;
  height: 46px;
  background: var(--SOFT-BG);
  border-radius: 26px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
}
.clock .date { font-size: 12px; white-space: nowrap; }
.clock .exp {
  background: #fff;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.clock .exp.ok { color: var(--SUCCESS); }
.clock .exp.soon { color: var(--WARN); }
.clock .exp.bad { color: var(--DANGER); }
.clock .grow { flex: 1; }
.clock .time { font-size: 13px; white-space: nowrap; }
.clock .ampm { font-size: 9px; color: var(--MUTED); }

.chip {
  height: 32px;
  border-radius: 20px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  background: var(--PILL-MID);
  color: var(--MUTED);
  white-space: nowrap;
}
.chip.ok { background: var(--PILL-OK); color: var(--SUCCESS); }
.chip.bad { background: var(--PILL-BAD); color: var(--DANGER); }
.chip.warn { background: var(--WARN-BG); color: var(--WARN-INK); }

.acct {
  height: 46px;
  border-radius: 26px;
  padding: 0 14px 0 18px;
  background: var(--FRAME);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.acct:hover { background: #4a4a4a; }

.statusline {
  margin: 10px 6px 0;
  font-size: 11px;
  color: var(--MUTED);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 16px;
}

.band {
  margin: 10px 6px 0;
  border-radius: 14px;
  background: var(--WARN-BG);
  color: var(--WARN-INK);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.band.err { background: var(--PILL-BAD); color: var(--DANGER); }
.band .grow { flex: 1; }

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 8px;
  padding: 2px 6px 18px;
  scrollbar-width: thin;
}
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: #d6d6d6; border-radius: 6px; border: 3px solid var(--PANEL); }

.page-loading { color: var(--MUTED); font-size: 12px; padding: 20px 4px; }

/* ------------------------------------------------------------------ grid -- */
.sec {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 4px 10px;
}
.sec:first-child { margin-top: 6px; }
.sec h2 { margin: 0; font-size: 14px; font-weight: 700; }
.sec .grow { flex: 1; }
.sec .hint { font-size: 10px; color: var(--SOFT); }

.rows { display: flex; flex-direction: column; gap: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.cols.wide { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.span2 { grid-column: span 2; }

.card {
  background: var(--CARD);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--SHADOW);
  min-width: 0;
}
.card.dark { background: var(--FRAME); color: #fff; }
.card.blue { background: var(--PRIMARY); }
.card.plain { box-shadow: none; background: var(--CARD2); }

.card .k { font-size: 11px; color: var(--MUTED); font-weight: 700; }
.card.dark .k { color: #b9bec6; }
.card .v { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: .3px; }
.card .v.sm { font-size: 17px; }
.card .foot { margin-top: 10px; font-size: 11px; color: var(--MUTED); }
.card.dark .foot { color: #d8d8d8; }

.stat { display: flex; align-items: center; gap: 14px; }
.stat .ring {
  width: 46px; height: 46px; border-radius: 15px;
  background: var(--SOFT-BG); color: var(--FRAME);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.stat .ring.blue { background: var(--PRIMARY); }

/* ---------------------------------------------------------------- table --- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.tbl th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--SOFT);
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 0 12px 2px;
  white-space: nowrap;
}
.tbl td {
  background: var(--ROW);
  padding: 11px 12px;
  font-size: 12.5px;
  vertical-align: middle;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbl tr td:first-child { border-radius: 12px 0 0 12px; }
.tbl tr td:last-child { border-radius: 0 12px 12px 0; }
.tbl tbody tr:hover td { background: #f0f0f0; }
.tbl .mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 11.5px; }
.tbl .strong { font-weight: 700; }
.tbl .empty { text-align: center; color: var(--MUTED); padding: 22px; background: var(--ROW); border-radius: 12px; }

.pill {
  display: inline-block;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  background: var(--PILL-MID);
  color: var(--MUTED);
  text-transform: uppercase;
}
.pill.ok { background: var(--PILL-OK); color: var(--SUCCESS); }
.pill.bad { background: var(--PILL-BAD); color: var(--DANGER); }
.pill.blue { background: var(--PRIMARY); color: var(--SEL-INK); }
.pill.warn { background: var(--WARN-BG); color: var(--WARN-INK); }

/* ------------------------------------------------------------- controls --- */
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bar .grow { flex: 1; }
/* A search field is the one control in a bar that should take the slack, so
   the button beside it is a button and not a full-width slab. */
.bar .input.search { flex: 1; min-width: 240px; }

.bar .input, .bar select.input { height: 38px; border-radius: 19px; width: auto; min-width: 180px; }
.bar .btn { height: 38px; border-radius: 19px; }

.pager { display: flex; align-items: center; gap: 8px; margin: 12px 4px 0; font-size: 12px; color: var(--MUTED); }
.pager .grow { flex: 1; }

.form { display: grid; gap: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: block; font-size: 11px; font-weight: 700; color: var(--MUTED); margin: 0 0 5px 4px; }

.addr {
  background: var(--SOFT-BG);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: Consolas, "SF Mono", Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 10px;
}
.addr .grow { flex: 1; }

.hintbox {
  border-radius: 14px;
  background: var(--SOFT-BG);
  color: var(--MUTED);
  padding: 12px 14px;
  font-size: 12px;
}
.hintbox.warn { background: var(--WARN-BG); color: var(--WARN-INK); }
.hintbox.bad { background: var(--PILL-BAD); color: var(--DANGER); }
.hintbox.ok { background: var(--PILL-OK); color: var(--SUCCESS); }

.plan { display: flex; flex-direction: column; gap: 6px; }
.plan .nm { font-size: 15px; font-weight: 700; }
.plan .pr { font-size: 24px; font-weight: 700; }
.plan .pr span { font-size: 12px; font-weight: 600; color: var(--MUTED); }
.plan ul { margin: 6px 0 2px; padding: 0; list-style: none; display: grid; gap: 5px; }
.plan li { font-size: 12px; color: var(--MUTED); display: flex; gap: 7px; align-items: flex-start; }
.plan li .i { color: var(--SUCCESS); margin-top: 1px; }
.plan.now { outline: 2px solid var(--PRIMARY); outline-offset: -2px; }

.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.slot { display: flex; gap: 12px; align-items: center; }
.slot .n {
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--SOFT-BG); color: var(--MUTED);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex: 0 0 auto;
}
.slot.on .n { background: var(--PRIMARY); color: var(--SEL-INK); }
.slot .info { flex: 1; min-width: 0; }
.slot .nm { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .sub { font-size: 11px; color: var(--MUTED); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.acts { display: flex; gap: 6px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 12.5px; }
.kv .k { color: var(--MUTED); font-size: 11px; font-weight: 700; }
.kv .v { text-align: right; }

.bars { display: flex; gap: 3px; align-items: flex-end; height: 74px; }
.bars i { flex: 1; background: var(--PRIMARY); border-radius: 4px 4px 0 0; min-height: 3px; display: block; }

.tl { display: flex; flex-direction: column; gap: 10px; }
.tl .ev { display: flex; gap: 10px; align-items: flex-start; font-size: 12px; }
.tl .ev .ic {
  width: 28px; height: 28px; border-radius: 10px; flex: 0 0 auto;
  background: var(--SOFT-BG); color: var(--MUTED);
  display: flex; align-items: center; justify-content: center;
}
.tl .ev .tx { min-width: 0; }
.tl .ev .m { color: var(--MUTED); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- toast --- */
.toasts {
  position: fixed;
  right: 26px; bottom: 26px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 60;
}
.toast {
  background: var(--FRAME); color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 12.5px;
  max-width: 320px;
  box-shadow: 0 14px 34px rgba(0,0,0,.28);
  animation: pop .16s ease-out;
}
.toast.ok { background: var(--SUCCESS); }
.toast.err { background: var(--DANGER); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-wrap {
  position: fixed; inset: 0;
  background: rgba(31,31,31,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
}
.modal {
  background: var(--CARD);
  border-radius: 22px;
  padding: 22px;
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .close { position: absolute; }

.spin {
  width: 15px; height: 15px;
  border: 2px solid rgba(31,31,31,.25);
  border-top-color: var(--INK);
  border-radius: 50%;
  animation: sp .7s linear infinite;
  display: inline-block;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 1100px) {
  .clock .date { display: none; }
  .acct .lbl { display: none; }
  .acct { padding: 0 14px; }
}
@media (max-width: 860px) {
  .shell { padding: 0; }
  .frame { border-radius: 0; padding: 0; gap: 0; }
  .rail {
    width: 60px; flex: 0 0 60px;
    padding: 14px 0;
  }
  .rail-item { width: 42px; height: 42px; border-radius: 13px; }
  .panel { border-radius: 0; }
  .head { gap: 10px; }
  .greet .g2, .clock .exp .lbl { display: none; }
  .cols { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
