/* homelab panel — Fermag design language (cream / terracotta, hairlines) */

:root {
  --paper: #FAF9F5;
  --ink: #262624;
  --muted: #6F6D64;
  --faint: #8F8C82;
  --line: #E7E4DC;
  --line-strong: #D8D4C9;
  --card: #FFFFFF;
  --soft: #F3F1EA;
  --accent: #C96442;
  --accent-deep: #A94F31;
  --accent-soft: #F7E8E1;
  --ok: #2F7D5D;
  --ok-soft: #E7F2EC;
  --warn: #9A6F22;
  --warn-soft: #F8F0DD;
  --danger: #B0432F;
  --danger-soft: #F9E7E2;
  --shadow: 0 1px 2px rgba(38, 38, 36, .04), 0 10px 30px rgba(38, 38, 36, .06);
  --radius: 14px;
}

html[data-theme="dark"] {
  --paper: #131311;
  --ink: #F1EFE8;
  --muted: #A3A099;
  --faint: #7F7C74;
  --line: #282826;
  --line-strong: #3A3934;
  --card: #1A1A18;
  --soft: #22221F;
  --accent: #D97A58;
  --accent-deep: #E08A6B;
  --accent-soft: #2B201B;
  --ok: #5FBF94;
  --ok-soft: #1B2A23;
  --warn: #D9AE63;
  --warn-soft: #2A2418;
  --danger: #E2795F;
  --danger-soft: #2B1D19;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 40px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ic { width: 16px; height: 16px; flex: none; }
.ic.sm { width: 14px; height: 14px; }
.ic.lg { width: 22px; height: 22px; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.top-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #FAF9F5;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.mark .ic { width: 17px; height: 17px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.brand-text em { font-style: normal; font-size: 10.5px; color: var(--faint); letter-spacing: .02em; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.lat {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 9px; margin-right: 4px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.off { background: var(--danger); }
.dot.warn { background: var(--warn); }
.lat .mono { font-size: 11px; }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

.tabs {
  display: flex; gap: 2px; margin: 18px 0 24px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 13px 12px; border: 0; background: transparent;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.tab .ic { width: 15px; height: 15px; opacity: .85; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab.active .ic { color: var(--accent); opacity: 1; }

.view { min-height: 58vh; animation: viewIn .22s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.hero h1 { margin: 0; font-size: 27px; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.hero p { margin: 6px 0 0; color: var(--muted); font-size: 13px; max-width: 640px; }
.hero-right { display: flex; align-items: center; gap: 8px; flex: none; padding-bottom: 2px; }
.meta { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- panels ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.panel + .panel, .grid2 + .panel, .panel + .grid2 { margin-top: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.panel-head h2 {
  margin: 0; font-size: 10.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
  display: inline-flex; align-items: center; gap: 7px;
}
.panel-head h2 .ic { width: 13px; height: 13px; }
.panel-head .right { display: flex; align-items: center; gap: 8px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 > *, .panel { min-width: 0; }

/* ---------- stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0; overflow: hidden;
}
.stat { padding: 15px 17px 13px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat-label {
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); display: flex; align-items: center; gap: 5px;
}
.stat-label .ic { width: 12px; height: 12px; }
.stat-value {
  font-size: 27px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15;
  margin-top: 3px; font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.stat-sub { font-size: 11px; color: var(--faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 9px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s ease; }
.bar.hot i { background: var(--danger); }
.spark { width: 100%; height: 28px; display: block; margin-top: 7px; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: color-mix(in srgb, var(--accent) 11%, transparent); stroke: none; }
.spark .line.cool { stroke: var(--muted); }

/* ---------- rows ---------- */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 8.5px 0; border-top: 1px solid var(--line); font-size: 12.5px;
}
.row:first-child { border-top: 0; padding-top: 2px; }
.row:last-child { padding-bottom: 2px; }
.row .k { color: var(--muted); flex: none; }
.row .v { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .v.mono { font-size: 11.5px; }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; text-align: left;
  padding: 0 10px 7px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--soft) 60%, transparent); }
.tbl .num { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tbl .right { text-align: right; }
.tbl .nowrap { white-space: nowrap; }
.name b { display: block; font-weight: 600; font-size: 12.5px; line-height: 1.35; }
.name span { display: block; color: var(--faint); font-size: 11px; line-height: 1.35; }

/* ---------- badges / buttons ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 19px; padding: 0 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: .03em;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.soft { background: var(--soft); border-color: transparent; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.err { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.acc { color: var(--accent-deep); background: var(--accent-soft); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--soft); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 14px; height: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--soft); color: var(--ink); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 11.5px; border-radius: 8px; }
.btn.sm .ic { width: 13px; height: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.iconbtn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--soft); color: var(--ink); }
.iconbtn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.sw {
  position: relative; width: 36px; height: 21px; border-radius: 999px;
  background: var(--line-strong); border: 0; cursor: pointer; flex: none;
  transition: background .15s;
}
.sw::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}
.sw.on { background: var(--accent); }
.sw.on::after { transform: translateX(15px); }
.sw[disabled] { opacity: .5; pointer-events: none; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.field .hint { margin: 0; }
input, select, textarea {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; }
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.hint { font-size: 11px; color: var(--faint); line-height: 1.45; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; height: 36px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--paper); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-err {
  margin-top: 2px; margin-bottom: 12px; padding: 8px 10px;
  border-radius: 8px; background: var(--danger-soft); color: var(--danger);
  font-size: 11.5px; line-height: 1.45;
}
.form-warn {
  margin-top: 10px; padding: 8px 10px; border-radius: 8px;
  background: var(--warn-soft); color: var(--warn); font-size: 11.5px; line-height: 1.45;
}

/* ---------- empty ---------- */
.empty { text-align: center; padding: 40px 18px 36px; color: var(--muted); }
.empty .ic { width: 26px; height: 26px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.empty p { margin: 0 0 14px; font-size: 12.5px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 372px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 24px 24px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -.025em; }
.login p { margin: 0 0 20px; font-size: 12.5px; color: var(--muted); }
.login-err {
  margin-top: 12px; padding: 9px 11px; border-radius: 9px;
  background: var(--danger-soft); color: var(--danger); font-size: 12px;
}

/* ---------- modal ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 200; padding: 20px;
  background: rgba(20, 20, 18, .44);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 468px; max-height: calc(100dvh - 40px);
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line); flex: none;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 13px 18px; border-top: 1px solid var(--line);
  background: var(--soft); flex: none;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 300;
  display: flex; align-items: flex-start; gap: 9px;
  max-width: min(430px, calc(100vw - 32px));
  padding: 11px 14px; border-radius: 11px;
  background: var(--ink); color: var(--paper);
  font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
  animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast .ic { margin-top: 1px; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- footer ---------- */
.foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 30px; padding: 16px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--faint); font-size: 10.5px;
}
.foot .mono { font-size: 10.5px; }

/* ---------- helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline { display: inline-flex; align-items: center; gap: 7px; }
.spacer { flex: 1; }
.tr { text-align: right; }
.wrap-anywhere { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(4) { border-top: 1px solid var(--line); }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .top-inner, .wrap { padding-left: 16px; padding-right: 16px; }
  .brand-text em { display: none; }
  .hero { flex-direction: column; align-items: flex-start; gap: 10px; }
  .hero h1 { font-size: 23px; }
  .hero-right { width: 100%; justify-content: space-between; }
  .tabs { margin: 14px -16px 18px; padding: 0 10px; }
  .panel { padding: 14px; }
  .tbl.responsive thead { display: none; }
  .tbl.responsive tbody tr {
    display: block; padding: 11px 0; border-bottom: 1px solid var(--line);
  }
  .tbl.responsive tbody tr:last-child { border-bottom: 0; }
  .tbl.responsive td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 3px 0; border: 0; text-align: right;
  }
  .tbl.responsive td::before {
    content: attr(data-label); flex: none;
    font-size: 9.5px; font-weight: 600; letter-spacing: .09em;
    text-transform: uppercase; color: var(--faint);
  }
  .tbl.responsive td.rowname { display: block; text-align: left; padding-bottom: 6px; }
  .tbl.responsive td.rowname::before { display: none; }
  .tbl.responsive td.actions { justify-content: flex-end; padding-top: 8px; }
  .tbl.responsive td.actions::before { display: none; }
  .foot { flex-direction: column; align-items: flex-start; gap: 4px; }
  .login-card { padding: 22px 20px; }
  .two { grid-template-columns: 1fr; }
  .toast { right: 16px; bottom: 16px; left: 16px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
