/* ==========================================================================
   Panel VPS — Admin stylesheet
   --------------------------------------------------------------------------
   Design language: WordPress Admin (structure, information hierarchy,
   practical density) with a modern execution.

   One file, no framework, no external network requests.

   Sections
     1. Design tokens
     2. Base / reset
     3. Layout shell (sidebar + content)
     4. Sidebar navigation
     5. Page header
     6. Cards (postbox)
     7. Notices
     8. Buttons
     9. Forms
    10. Tables
    11. Badges & status
    12. Stat cards & activity
    13. Empty states
    14. Auth pages
    15. Utilities
    16. Responsive
   ========================================================================== */

/* ── 1. Design tokens ───────────────────────────────────────────────────── */

:root {
  /* Surface */
  --bg:            #f0f0f1;
  --surface:       #ffffff;
  --surface-alt:   #f6f7f7;
  --border:        #c3c4c7;
  --border-light:  #e5e5e5;
  --border-faint:  #f0f0f1;

  /* Text */
  --text:          #1d2327;
  --text-soft:     #50575e;
  --text-muted:    #646970;

  /* Brand */
  --primary:       #2271b1;
  --primary-hover: #135e96;
  --primary-dark:  #0a4b78;

  /* Sidebar (dark chrome) */
  --nav-bg:        #1d2327;
  --nav-text:      #f0f0f1;
  --nav-muted:     #a7aaad;
  --nav-hover-bg:  #2c3338;
  --nav-hover-fg:  #72aee6;
  --nav-active-bg: #2271b1;

  /* Semantic */
  --ok:            #00a32a;
  --ok-bg:         #edfaef;
  --err:           #d63638;
  --err-bg:        #fcf0f1;
  --warn:          #dba617;
  --warn-bg:       #fef8ee;
  --info:          #72aee6;

  /* Shape */
  --radius:        4px;
  --radius-lg:     8px;
  --shadow-sm:     0 1px 1px rgba(0, 0, 0, .04);
  --shadow:        0 1px 3px rgba(0, 0, 0, .08);
  --shadow-lg:     0 4px 16px rgba(0, 0, 0, .12);

  /* Metrics */
  --nav-w:         210px;
  --topbar-h:      46px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans,
          Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

/* ── 2. Base / reset ────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p  { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

code, .mono { font-family: var(--mono); font-size: 12px; }
code {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-soft);
}

hr { border: 0; border-top: 1px solid var(--border-light); margin: 18px 0; }

/* ── 3. Layout shell ────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--nav-w);
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.content {
  margin-left: var(--nav-w);
  padding: 22px 26px 40px;
  min-height: 100vh;
}

.content-inner { max-width: 1180px; }

/* Slim bar that only appears on small screens */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-h);
  background: var(--nav-bg);
  color: var(--nav-text);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}
.topbar-title { font-size: 14px; font-weight: 600; }
.topbar-spacer { flex: 1; }

.nav-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .25);
  color: var(--nav-text);
  border-radius: var(--radius);
  /* 44x44 is the minimum comfortable touch target on a phone. */
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  margin: -7px 0;   /* keep the topbar the same visual height */
}
.nav-toggle:hover { background: var(--nav-hover-bg); border-color: var(--nav-hover-fg); }
.nav-toggle svg { width: 19px; height: 19px; }

/* ── 4. Sidebar navigation ──────────────────────────────────────────────── */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { color: var(--nav-text); font-size: 13px; font-weight: 600; }
.brand-sub  { color: var(--nav-muted); font-size: 11px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 0; }

.nav-section {
  padding: 12px 16px 6px;
  color: var(--nav-muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--nav-text);
  font-size: 13px;
  border-left: 4px solid transparent;
}
.nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-hover-fg);
  text-decoration: none;
}
.nav-item.is-active {
  background: var(--nav-active-bg);
  color: #fff;
  border-left-color: var(--nav-hover-fg);
  font-weight: 600;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .9; }
.nav-count {
  margin-left: auto;
  background: rgba(255, 255, 255, .14);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.nav-item.is-active .nav-count { background: rgba(255, 255, 255, .25); }

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, .09);
  padding: 12px 16px;
}
.who { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.who-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #3c434a; color: var(--nav-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex: 0 0 auto;
}
.who-name { color: var(--nav-text); font-size: 12.5px; font-weight: 600; }
.who-role { color: var(--nav-muted); font-size: 11px; }
.logout {
  display: block;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  padding: 6px;
  color: var(--nav-muted);
  font-size: 12px;
}
.logout:hover {
  background: var(--nav-hover-bg);
  border-color: var(--err);
  color: #ff7b7b;
  text-decoration: none;
}

.nav-scrim { display: none; }

/* ── 5. Page header ─────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-title { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.page-desc  { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.breadcrumb { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ── 6. Cards (postbox) ─────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
}
.card-head h2 {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0;
}
.card-hint {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px; }
.card-body.is-flush { padding: 0; }

/* Column layouts */
.grid { display: grid; gap: 18px; align-items: start; }
.grid-main   { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); }
.grid-halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── 7. Notices ─────────────────────────────────────────────────────────── */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--info);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 11px 14px;
  margin-bottom: 16px;
}
.notice-icon { flex: 0 0 auto; margin-top: 1px; }
.notice-icon svg { width: 16px; height: 16px; display: block; }
.notice-text { flex: 1; font-size: 13px; color: var(--text-soft); }
.notice-text strong { color: var(--text); }

.notice.is-success { border-left-color: var(--ok); }
.notice.is-success .notice-icon { color: var(--ok); }
.notice.is-error   { border-left-color: var(--err); }
.notice.is-error   .notice-icon { color: var(--err); }
.notice.is-warning { border-left-color: var(--warn); }
.notice.is-warning .notice-icon { color: var(--warn); }
.notice.is-info    .notice-icon { color: var(--info); }

.notice-dismiss {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  flex: 0 0 auto;
}
.notice-dismiss:hover { color: var(--err); }

/* Monospace box for raw error output from Caddy */
.detail-box {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--err);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ── 8. Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
  text-decoration: none;
}

.btn.is-secondary {
  background: var(--surface-alt);
  border-color: var(--primary);
  color: var(--primary);
}
.btn.is-secondary:hover {
  background: #f0f0f1;
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}

.btn.is-danger {
  background: transparent;
  border-color: var(--err);
  color: var(--err);
}
.btn.is-danger:hover { background: var(--err); border-color: var(--err); color: #fff; }

.btn.is-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
}
.btn.is-ghost:hover {
  background: var(--surface-alt);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn.is-small { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 14px; height: 14px; }

/* Link-style action — WordPress "row action" feel */
.link-action {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--primary);
  cursor: pointer;
}
.link-action:hover { color: var(--primary-hover); text-decoration: underline; }
.link-action.is-danger { color: var(--err); }
.link-action.is-danger:hover { color: #b32d2e; }
.link-action.is-muted { color: var(--text-muted); }
.link-action.is-muted:hover { color: var(--primary); }

.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions .sep { color: var(--border); }
.row-actions form { display: inline; margin: 0; }

/* ── 9. Forms ───────────────────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.help {
  display: block;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 400;
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
input[type="search"],
input:not([type]),
select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-height: 34px;
}
input::placeholder { color: #a7aaad; }
input:hover, select:hover { border-color: var(--text-muted); }
input:focus, select:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(34, 113, 177, .25);
  outline-offset: -1px;
}
/* The `type` attribute is optional in HTML; add it explicitly in markup so
   these rules apply. Covered by `input:not([type])` above as a safety net. */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2350575e'%3E%3Cpath d='M5 7l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
  padding-right: 32px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* Constraint reference (allowed ports / roots) */
.constraints {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-soft);
}
.constraints dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
}
.constraints dt { font-weight: 600; color: var(--text); }
.constraints dd { margin: 0; word-break: break-word; }
.constraints code { margin-right: 4px; }

/* ── 10. Tables ─────────────────────────────────────────────────────────── */

/* Horizontal scroll on a narrow screen is invisible without a cue, so the
   table looked "cut off" instead of scrollable. The two gradients below are
   `local` (scroll with the content) against `scroll` (stay pinned to the
   padding box) — the classic shadow trick, pure CSS, no JS.
   The wrapper owns the white background and the table stays transparent, so
   the shadows are visible *through* the rows instead of behind them. */
.table-wrap {
  overflow-x: auto;
  background-color: var(--surface);
  background-image:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)),
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .13), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .13), rgba(0, 0, 0, 0));
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  /* Transparent on purpose: .table-wrap supplies the white and the
     scroll-shadow gradients must show through the rows. */
  background: transparent;
}

table.list thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  white-space: nowrap;
}
table.list tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-faint);
  vertical-align: middle;
}
table.list tbody tr:hover { background: #fbfbfc; }
table.list tbody tr:last-child td { border-bottom: 0; }

.col-domain  { min-width: 190px; }
/* Never break an address apart: `127.0.0.1:8088` must stay on one line.
   `.table-wrap` already scrolls horizontally, so wide values stay readable
   instead of being chopped into fragments. */
.col-target  { white-space: nowrap; }
.col-status  { width: 96px; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }

.cell-primary { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }

/* ── 11. Badges & status ────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.is-on {
  background: var(--ok-bg);
  color: #007017;
  border-color: #b8e6c1;
}
.badge.is-off {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: var(--border-light);
}
.badge.is-proxy {
  background: #eef6fc;
  color: var(--primary-dark);
  border-color: #c5dff0;
}
.badge.is-static {
  background: #f7f2fa;
  color: #6c3f8f;
  border-color: #e0cfea;
}
.badge.is-warn {
  background: var(--warn-bg);
  color: #8a6100;
  border-color: #f0d9a8;
}
.badge.is-err {
  background: var(--err-bg);
  color: #a02224;
  border-color: #f0c2c3;
}
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}

/* ── 12. Stat cards & activity ──────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 15px;
}
.stat.is-ok  { border-left-color: var(--ok); }
.stat.is-off { border-left-color: var(--text-muted); }
.stat.is-err { border-left-color: var(--err); }
.stat-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 4px;
}
.stat-note { color: var(--text-soft); font-size: 11.5px; margin-top: 3px; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-faint);
}
.activity li:last-child { border-bottom: 0; }
.activity li:first-child { padding-top: 0; }
.activity-mark {
  width: 7px; height: 7px; border-radius: 50%;
  margin-top: 6px; flex: 0 0 auto;
  background: var(--ok);
}
.activity-mark.is-fail { background: var(--err); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 12.5px; font-weight: 600; }
.activity-meta { color: var(--text-muted); font-size: 11.5px; margin-top: 1px; }
.activity-detail {
  color: var(--text-soft);
  font-size: 11.5px;
  font-family: var(--mono);
  margin-top: 2px;
  word-break: break-word;
}

/* ── 13. Empty states ───────────────────────────────────────────────────── */

.empty { text-align: center; padding: 34px 20px; }
.empty-icon {
  width: 40px; height: 40px;
  margin: 0 auto 12px;
  color: var(--border);
}
.empty-icon svg { width: 100%; height: 100%; display: block; }
.empty-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.empty-text {
  color: var(--text-muted);
  font-size: 12.5px;
  max-width: 400px;
  margin: 0 auto;
}

/* ── 14. Auth pages ─────────────────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 18px;
}
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.auth-brand .brand-mark { width: 32px; height: 32px; font-size: 14px; }
.auth-brand .brand-name { color: var(--text); font-size: 15px; font-weight: 600; }

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px 24px 22px;
}
.auth-card h1 { font-size: 16px; margin-bottom: 6px; }
.auth-desc {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-bottom: 18px;
}
.auth-card .btn { width: 100%; }
.auth-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
}
.auth-page-foot {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
}
.auth-card .notice { margin-bottom: 16px; }

/* ── 15. Utilities ──────────────────────────────────────────────────────── */

.muted      { color: var(--text-muted); }
.soft       { color: var(--text-soft); }
.small      { font-size: 11.5px; }
.nowrap     { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0       { margin-top: 0; }
.mb-0       { margin-bottom: 0; }
.mb-12      { margin-bottom: 12px; }
.mb-18      { margin-bottom: 18px; }
.flex       { display: flex; align-items: center; gap: 10px; }
.flex-wrap  { flex-wrap: wrap; }
.spacer     { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Inline DNS check result inside a table row */
.dns-result { font-size: 11.5px; margin-top: 3px; }
.dns-result.is-ok   { color: var(--ok); }
.dns-result.is-warn { color: #8a6100; }
.dns-result.is-err  { color: var(--err); }
.dns-result.is-busy { color: var(--text-muted); }

/* ── 16. Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1400px) {
  /* The domain table needs ~740px to show all five columns comfortably.
     Below that, stack the add-form under the table (WordPress list-table
     style) instead of squeezing the table into 1.62fr. */
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .grid-halves { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 783px) {
  .topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .nav-scrim {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 95;
  }
  body.nav-open .nav-scrim { display: block; }

  .content { margin-left: 0; padding: 16px 14px 32px; }
  .page-title { font-size: 18px; }
  .page-head-actions { margin-left: 0; width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-actions { text-align: left; }
  table.list thead th, table.list tbody td { padding: 9px 10px; }

  /* Touch targets: a fingertip needs ~44px. Desktop keeps the compact
     WordPress-style row actions; on a phone they get real padding so
     "Xoá" is not a 20px bullseye next to "Tắt". No negative margins here —
     they made adjacent actions overlap, so a tap could hit the wrong one. */
  .link-action { padding: 11px 10px; }
  .row-actions { gap: 2px; }
  .row-actions .sep { margin: 0 1px; }
  .notice-dismiss { padding: 12px; }
  .logout { padding-top: 11px; padding-bottom: 11px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .constraints dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .constraints dt { margin-top: 6px; }
}

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