/* AXureous Backup: dark theme matching the Optanik Dashboard. */
:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: #0c111cd9;
  --edge: #3aa0ff26;
  --ink: #f4f7fb;
  --muted: #8b95a8;
  --dim: #64748b;
  --blue: #3aa0ff;
  --cyan: #7ec8ff;
  --violet: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --run: #60a5fa;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #3aa0ff1a, transparent), radial-gradient(900px 500px at 100% 0, #8b5cf61a, transparent), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 14px/1.45 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}
a { color: var(--cyan); }
h1, h2, h3 { margin: 0 0 0.8rem; font-weight: 600; }
h2 { font-size: 1.02rem; }
h3 { font-size: 0.92rem; margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
code, pre { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12.5px; }
pre { background: #000a; border: 1px solid var(--edge); border-radius: 8px; padding: 0.8rem; overflow-x: auto; white-space: pre; }

.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 0.5rem 0.95rem; font: inherit; font-weight: 600;
  cursor: pointer; color: var(--ink); background: #ffffff10; white-space: nowrap;
}
.btn:hover { background: #ffffff1c; }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--violet)); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { border-color: #ffffff22; background: transparent; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

input, select {
  font: inherit; color: var(--ink); background: #0008; border: 1px solid #ffffff24; border-radius: 8px; padding: 0.5rem 0.65rem; width: 100%;
}
input:focus, select:focus { outline: 2px solid #3aa0ff66; border-color: var(--blue); }
input[type='checkbox'] { width: auto; accent-color: var(--blue); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 0.7rem; text-align: center; background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 2rem 1.6rem; }
.login-card img { justify-self: center; }
.login-card h1 { margin: 0; font-size: 1.3rem; }
.login-card p { margin: 0; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: 0.7rem 1.4rem; background: #05070dcc; backdrop-filter: blur(14px); border-bottom: 1px solid var(--edge);
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-size: 1.05rem; white-space: nowrap; }
.brand b { color: var(--cyan); }
.tabs { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 500; padding: 0.45rem 0.8rem; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); background: #3aa0ff22; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

main { padding: 1.2rem 1.4rem 3rem; max-width: 1500px; margin: 0 auto; display: block; }
section { display: grid; gap: 1rem; }
section[hidden] { display: none; }

.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 1rem 1.1rem; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.panel-head h2 { margin: 0 auto 0 0; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; }

.banner { padding: 0.7rem 1rem; border-radius: 10px; background: #3aa0ff1a; border: 1px solid #3aa0ff40; }
.banner.warn { background: #fbbf2414; border-color: #fbbf2440; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.8rem; }
.tile { background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 0.85rem 1rem; cursor: pointer; }
.tile .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 12.5px; }
.tile.ok .n { color: var(--ok); }
.tile.warn .n { color: var(--warn); }
.tile.bad .n { color: var(--bad); }
.tile.run .n { color: var(--run); }
.tile.zero .n { color: var(--dim); }

/* server strip */
.servers-strip { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.srv { display: flex; align-items: center; gap: 0.5rem; background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; padding: 0.45rem 0.8rem; font-size: 13px; }
.srv .sub { color: var(--muted); font-size: 12px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px currentColor; color: var(--ok); flex: none; }
.dot.bad { background: var(--bad); color: var(--bad); }
.dot.warn { background: var(--warn); color: var(--warn); }
.dot.off { background: var(--dim); color: transparent; }

/* tables */
.filters { display: flex; gap: 0.5rem; }
.filters input { width: 220px; }
.filters select { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 0.45rem 0.6rem; border-bottom: 1px solid #ffffff14; white-space: nowrap; }
th[data-sort] { cursor: pointer; }
th[data-sort]:hover { color: var(--ink); }
td { padding: 0.5rem 0.6rem; border-bottom: 1px solid #ffffff0d; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
.name { font-weight: 600; }
.sub { color: var(--muted); font-size: 12px; }
.err { color: var(--bad); font-size: 12px; max-width: 420px; }

.pill { display: inline-block; padding: 0.12rem 0.55rem; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: #34d39922; color: var(--ok); }
.pill.overdue { background: #fbbf2422; color: var(--warn); }
.pill.failed, .pill.gave_up { background: #f8717122; color: var(--bad); }
.pill.retrying { background: #60a5fa22; color: var(--run); }
.pill.excluded, .pill.unscheduled { background: #ffffff10; color: var(--dim); }
.age.warn { color: var(--warn); }
.age.bad { color: var(--bad); }

/* pbs */
.store { padding: 0.6rem 0; border-bottom: 1px solid #ffffff0d; }
.store:last-child { border-bottom: 0; }
.bar { height: 7px; background: #ffffff12; border-radius: 6px; overflow: hidden; margin: 0.35rem 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--violet)); }
.bar.warn i { background: var(--warn); }
.bar.bad i { background: var(--bad); }

/* forms */
.form { display: grid; gap: 0.8rem; }
.form h2 { margin: 0.4rem 0 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.8rem; }
.row .narrow { max-width: 130px; }
.row.checks { display: flex; gap: 1.4rem; flex-wrap: wrap; }
label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 12.5px; }
label.check { display: flex; align-items: center; gap: 0.45rem; color: var(--ink); font-size: 13.5px; }
.actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.result { font-size: 13px; }
.result.ok { color: var(--ok); }
.result.bad { color: var(--bad); }
.help p { color: var(--muted); max-width: 900px; }

.srv-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.7rem 0; border-bottom: 1px solid #ffffff0d; flex-wrap: wrap; }
.srv-row:last-child { border-bottom: 0; }
.srv-row .grow { flex: 1; min-width: 220px; }

.events .ev { display: flex; gap: 0.8rem; padding: 0.35rem 0; border-bottom: 1px solid #ffffff0a; font-size: 13px; }
.events .ev time { color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.events .ev.error span { color: var(--bad); }
.events .ev.warn span { color: var(--warn); }

dialog { background: #0c111c; color: var(--ink); border: 1px solid var(--edge); border-radius: 14px; padding: 1.2rem; width: min(460px, calc(100% - 32px)); }
dialog::backdrop { background: #000a; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0c111c; border: 1px solid var(--edge); padding: 0.6rem 1rem; border-radius: 10px; z-index: 20; }
.toast.bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 1100px) {
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .top { padding: 0.6rem 16px; gap: 0.6rem; }
  main { padding: 1rem 16px 2rem; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .filters { width: 100%; }
  .filters input { width: 100%; }
  .top-right #last-check { display: none; }
}

/* keep wide tables scrolling inside their panel on small screens */
section > *, .grid2 > * { min-width: 0; }
table.guests { min-width: 820px; }
table.tasks { min-width: 520px; }

/* icons in header buttons */
.btn .ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; margin-right: 0.4rem; }
.btn.spin .ic { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.m-only { display: none; }

/* ---------- phone layout: compact header, counters in one row, tables as cards ---------- */
@media (max-width: 640px) {
  body { font-size: 13.5px; }
  .m-only { display: inline; }

  .top { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0.5rem; padding: 0.5rem 12px 0; }
  .brand { font-size: 0.98rem; }
  .brand img { width: 24px; height: 24px; }
  .top-right { gap: 0.35rem; grid-row: 1; grid-column: 2; }
  .top-right .btn { padding: 0.4rem 0.55rem; }
  .top-right .lbl, .top-right #last-check { display: none; }
  .btn .ic { margin-right: 0; }
  .tabs { grid-column: 1 / -1; grid-row: 2; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 8px 0.35rem; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 0.35rem 0.7rem; font-size: 13px; flex: none; }

  main { padding: 0.7rem 10px 2rem; }
  section { gap: 0.7rem; }
  .panel { padding: 0.75rem 0.8rem; border-radius: 12px; }
  .panel h2, .panel-head h2 { font-size: 0.95rem; margin-bottom: 0.5rem; }
  .panel-head { margin-bottom: 0.4rem; }
  .banner { padding: 0.5rem 0.7rem; font-size: 12.5px; }

  .tiles { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .tile { padding: 0.5rem 0.3rem; border-radius: 10px; text-align: center; }
  .tile .n { font-size: 1.35rem; }
  .tile .l { font-size: 10.5px; line-height: 1.2; }
  .tile:last-child { display: none; }

  .servers-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px; gap: 0.4rem; }
  .servers-strip::-webkit-scrollbar { display: none; }
  .srv { flex: none; padding: 0.35rem 0.6rem; font-size: 12.5px; }
  .srv .sub { font-size: 11px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .filters { width: 100%; }
  .filters input { flex: 1; width: auto; min-width: 0; }
  .filters input, .filters select { padding: 0.4rem 0.55rem; }

  /* VM table -> cards */
  table.guests, table.tasks { min-width: 0; }
  table.guests thead, table.tasks thead { display: none; }
  table.guests tbody, table.tasks tbody { display: grid; gap: 0.45rem; }
  table.guests tr {
    display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: 'name status act' 'age age age';
    gap: 0.15rem 0.5rem; padding: 0.55rem 0.65rem; background: #ffffff06; border: 1px solid #ffffff10; border-radius: 10px;
  }
  table.guests td { padding: 0; border: 0; }
  table.guests .c-id, table.guests .c-where, table.guests .c-limit, table.guests .c-job { display: none; }
  table.guests .c-name { grid-area: name; min-width: 0; }
  table.guests .c-act { grid-area: act; }
  table.guests .c-age { grid-area: age; }
  table.guests .c-status { grid-area: status; align-self: start; }
  table.guests .c-act .btn { padding: 0.15rem 0.55rem; }
  .err { max-width: none; }

  /* jobs table -> compact rows */
  table.tasks tr { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.5rem; padding: 0.45rem 0.6rem; background: #ffffff06; border-radius: 10px; }
  table.tasks td { padding: 0; border: 0; }
  table.tasks .c-took, table.tasks .c-where { display: none; }
  table.tasks .c-guests { grid-column: 1 / -1; }
  table.tasks .c-guests:empty { display: none; }

  .form .row { grid-template-columns: 1fr; gap: 0.6rem; }
  .row .narrow { max-width: none; }
  .row.checks { gap: 0.5rem 1rem; }
  .srv-row { gap: 0.5rem; }
  .srv-row .grow { min-width: 0; flex-basis: calc(100% - 30px); }
  pre { font-size: 11px; }
}
