/* HostDesk -- admin UI styles. No external fonts or CDNs, so the strict CSP holds. */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --surface-2: #fafbfc;
  --border:    #e2e5ea;
  --border-2:  #cdd3db;
  --text:      #17202e;
  --muted:     #5f6b7c;
  --faint:     #8b95a4;

  --accent:      #4f46e5;
  --accent-ink:  #ffffff;
  --accent-soft: #eef0fe;

  --ok:       #10794a;
  --ok-soft:  #e6f6ee;
  --warn:     #9a6100;
  --warn-soft:#fdf1dc;
  --crit:     #b32020;
  --crit-soft:#fdeaea;
  --info:     #1d4ed8;
  --info-soft:#e8effd;

  --radius:   10px;
  --radius-s: 7px;
  --shadow:   0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-l: 0 8px 24px rgba(16,24,40,.10);

  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1419;
    --surface:   #171d25;
    --surface-2: #1d242e;
    --border:    #29323e;
    --border-2:  #3a4553;
    --text:      #e6eaf0;
    --muted:     #9aa5b4;
    --faint:     #6f7c8c;

    --accent:      #7c76f2;
    --accent-ink:  #0f1419;
    --accent-soft: #22263f;

    --ok:       #4ade9a;  --ok-soft:  #14301f;
    --warn:     #f0b429;  --warn-soft:#332510;
    --crit:     #f87171;  --crit-soft:#3a1a1a;
    --info:     #7aa5f7;  --info-soft:#16233d;

    --shadow:   0 1px 2px rgba(0,0,0,.35);
    --shadow-l: 0 8px 24px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: .98rem; }
p  { margin: 0 0 1em; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--accent);
  color: var(--accent-ink); padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius-s) 0;
}
.skip:focus { left: 0; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; gap: .65rem; align-items: center; padding: 1.05rem 1rem; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: .82rem; letter-spacing: .04em; flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: .95rem; }
.brand-text small { color: var(--faint); font-size: .72rem; }

.nav { padding: .7rem .6rem; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; border-radius: var(--radius-s);
  color: var(--muted); font-weight: 500; font-size: .9rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ico { width: 1.1em; text-align: center; opacity: .85; }

.sidebar-foot { border-top: 1px solid var(--border); padding: .75rem; display: grid; gap: .55rem; }
.who { display: flex; gap: .55rem; align-items: center; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: 0 0 auto;
}
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-text strong { font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: var(--faint); font-size: .72rem; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .8rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 1.05rem; margin: 0; flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.menu-toggle {
  display: none; background: none; border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-s); padding: .35rem .6rem; cursor: pointer; font-size: 1rem;
}

.main { padding: 1.25rem; flex: 1; max-width: 1400px; width: 100%; }
.foot { padding: 1rem 1.25rem 1.75rem; color: var(--faint); font-size: .78rem; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.1rem;
}
.card-head {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.card-head h2 { margin: 0; flex: 1; min-width: 0; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 1.1rem; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .95rem 1.05rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 1.75rem; font-weight: 680; line-height: 1.15; margin-top: .25rem; letter-spacing: -.02em; }
.stat .sub   { color: var(--faint); font-size: .78rem; margin-top: .15rem; }
.stat.is-crit .value { color: var(--crit); }
.stat.is-warn .value { color: var(--warn); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 650; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
th a { color: inherit; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
.t-strong { font-weight: 600; }
.t-sub { color: var(--faint); font-size: .8rem; }
.mono { font-family: var(--mono); font-size: .85em; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: .3em;
  padding: .18em .55em; border-radius: 100px; font-size: .74rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-soft);   color: var(--ok);   border-color: transparent; }
.badge-soon    { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-warning { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-critical,
.badge-expired { background: var(--crit-soft); color: var(--crit); border-color: transparent; }
.badge-none    { background: var(--surface-2); color: var(--faint); }

.dot { width: .5em; height: .5em; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .48rem .85rem; border-radius: var(--radius-s); border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font: inherit; font-size: .87rem; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--crit); border-color: var(--crit); background: transparent; }
.btn-danger:hover { background: var(--crit-soft); }
.btn-ghost { border-color: var(--border); color: var(--muted); }
.btn-sm { padding: .3rem .55rem; font-size: .79rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */

.field { display: grid; gap: .3rem; margin-bottom: .95rem; }
.field label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field .hint { font-size: .77rem; color: var(--faint); }

input[type=text], input[type=password], input[type=email], input[type=url],
input[type=date], input[type=number], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; font: inherit; font-size: .9rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius-s);
}
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }

.check { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .95rem; }
.check input { width: auto; margin-top: .25rem; }
.check label { font-weight: 500; color: var(--text); font-size: .88rem; }

fieldset { border: 0; padding: 0; margin: 0 0 .5rem; }
legend {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; color: var(--faint); padding: 0 0 .55rem;
}

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { min-width: 200px; flex: 1 1 200px; }
.filters select { width: auto; min-width: 130px; }

/* ---------- Flash + toast ---------- */

.flash {
  padding: .7rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem;
  font-size: .89rem; border: 1px solid transparent;
}
.flash-success { background: var(--ok-soft);   color: var(--ok); }
.flash-error   { background: var(--crit-soft); color: var(--crit); }
.flash-info    { background: var(--info-soft); color: var(--info); }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem;
  border-radius: var(--radius-s); box-shadow: var(--shadow-l); font-size: .87rem; z-index: 200;
  max-width: calc(100vw - 2rem);
}

/* ---------- Empty state ---------- */

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h3 { color: var(--text); }
.empty p { max-width: 44ch; margin: 0 auto 1rem; font-size: .89rem; }

/* ---------- Detail lists ---------- */

.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: .45rem .9rem; font-size: .88rem; margin: 0; }
.dl dt { color: var(--muted); font-weight: 550; }
.dl dd { margin: 0; word-break: break-word; }

.svc { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .85rem; background: var(--surface); }
.svc-head {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .7rem .9rem; border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.svc-head .svc-title { font-weight: 620; flex: 1; min-width: 0; }
.svc-body { padding: .9rem; }

.cred { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.cred-value { font-family: var(--mono); font-size: .85rem; background: var(--surface-2); padding: .18rem .45rem; border-radius: 5px; border: 1px solid var(--border); }

/* ---------- Login / install ---------- */

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-l); padding: 1.75rem; }
.auth-card.wide { max-width: 640px; }
.auth-brand { display: flex; gap: .6rem; align-items: center; margin-bottom: 1.35rem; }
.auth-note { color: var(--faint); font-size: .78rem; text-align: center; margin: 1.15rem 0 0; }

.steps { counter-reset: step; display: grid; gap: .55rem; margin: 0 0 1.1rem; padding: 0; list-style: none; }
.steps li { display: flex; gap: .6rem; font-size: .87rem; color: var(--muted); }
.steps li::before {
  counter-increment: step; content: counter(step);
  width: 1.4rem; height: 1.4rem; flex: 0 0 auto; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .74rem; font-weight: 700;
}

.req { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .87rem; }
.req:last-child { border-bottom: 0; }
.req-pass { color: var(--ok); font-weight: 600; }
.req-fail { color: var(--crit); font-weight: 600; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-l);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .main { padding: 1rem; }
  .topbar { padding: .7rem 1rem; }
  .dl { grid-template-columns: 1fr; gap: .1rem .9rem; }
  .dl dd { margin-bottom: .5rem; }
}

@media print {
  .sidebar, .topbar, .foot, .btn, .filters { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
