:root {
  --ground: #F4F5F7;
  --card: #FFFFFF;
  --line: #E1E4E8;
  --line-soft: #EEF0F2;
  --ink: #1B1F24;
  --ink-2: #3A4049;
  --muted: #555C66;
  --accent: #0F766E;
  --accent-dark: #0F5F59;
  --warn-bg: #FFF1E0;
  --warn-fg: #8A4B0F;
  --ok-bg: #E7F4EC;
  --ok-fg: #1E6B3A;
  --off-bg: #EFF1F3;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.page { max-width: 1280px; margin: 0 auto; padding: 32px 24px 48px; }
h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0 0 12px; font-size: 20px; }
p { margin: 0; }
a { color: var(--accent-dark); font-weight: 600; }
a:hover { color: #0A4540; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
code.cmd { background: var(--card); padding: 2px 6px; border-radius: 4px; }

.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.sub { color: var(--muted); }
.error { color: #9B1C1C; font-weight: 600; }

button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #1D4ED8; outline-offset: 2px;
}
button.primary { border: 0; background: var(--accent); color: #FFFFFF; border-radius: 8px; padding: 10px 16px; font-weight: 600; min-height: 44px; }
button.primary:hover { background: var(--accent-dark); }
button.secondary { border: 1px solid #C9CED6; background: var(--card); color: var(--ink); border-radius: 8px; padding: 9px 14px; font-weight: 600; min-height: 40px; }
button.link { border: 0; background: none; padding: 4px 0; color: var(--accent-dark); font-weight: 600; text-decoration: underline; }
button.small { border: 1px solid #C9CED6; background: var(--card); color: var(--ink); border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 600; min-height: 28px; }

/* Gate screens */
.gate { max-width: 520px; margin: 12vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 32px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.gate label { font-weight: 600; }
.gate select { min-height: 40px; padding: 6px 8px; border: 1px solid #C9CED6; border-radius: 8px; min-width: 260px; }
#userdir-picker { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* App */
#screen-app { display: flex; flex-direction: column; gap: 20px; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.top > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.who { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.who .links { display: flex; gap: 14px; }
.machine-pick { display: flex; gap: 8px; align-items: center; }
.machine-pick select { min-height: 32px; border: 1px solid #C9CED6; border-radius: 6px; padding: 2px 6px; }

.notice { background: #EAF0FB; border: 1px solid #C3D3F0; color: #1D3A70; border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.problems { background: var(--warn-bg); border: 1px solid #F3D3AE; color: var(--warn-fg); border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.problems p + p { margin-top: 6px; }

.counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.count { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.count-label { font-size: 12px; color: var(--muted); }
.count-value { font-size: 24px; font-weight: 700; }
.count.attention { background: #FFF7ED; border-color: #F3D3AE; }
.count.attention .count-label, .count.attention .count-value { color: var(--warn-fg); }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 4px; background: #E7EAEE; padding: 4px; border-radius: 10px; }
.filters button { border: 0; border-radius: 7px; padding: 8px 14px; font-weight: 600; min-height: 36px; background: transparent; color: var(--muted); }
.filters button[aria-pressed="true"] { background: var(--card); color: var(--ink); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; min-width: 1040px; border-collapse: collapse; }
th { text-align: left; padding: 12px 20px; background: #F8F9FA; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
td { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td.empty { text-align: center; color: var(--muted); padding: 32px; }

.server-name { font-weight: 600; }
.server-desc { font-size: 13px; color: var(--muted); }
.server-tools { margin-top: 4px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.nextpro { background: #E6F1EF; color: #0F5F59; }
.badge.directory { background: #EAF0FB; color: #234A8C; }
.badge.local { background: #F1ECF8; color: #5B3A8C; }

.policy-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #C9CED6; background: var(--card); color: var(--ink-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; min-height: 36px; }
.policy-btn.mandatory { border-color: var(--accent); background: var(--accent); color: #FFFFFF; }
.policy-text { font-size: 13px; font-weight: 600; color: var(--ink-2); }

.enabled { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.enabled input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.enabled input:disabled { cursor: not-allowed; }

.reaches { font-size: 13px; color: var(--ink-2); }

.status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill .glyph { font-weight: 700; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.off, .pill.none { background: var(--off-bg); color: var(--muted); }
.status .tip { font-size: 12px; color: var(--muted); }
.status .note { flex-basis: 100%; font-size: 12px; color: var(--muted); }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; background: #EAF5F3; border: 1px solid #BFE0DB; border-radius: 12px; padding: 16px 20px; }
.foot > div { display: flex; flex-direction: column; gap: 4px; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(520px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(27, 31, 36, 0.45); }
dialog form { display: flex; flex-direction: column; gap: 8px; }
dialog label { font-weight: 600; margin-top: 6px; }
dialog label.check { font-weight: 400; display: flex; align-items: center; gap: 8px; }
dialog .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
dialog input[type="text"], dialog input[type="url"], dialog select, dialog textarea { border: 1px solid #C9CED6; border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0 0; padding: 8px 12px; }
dialog legend { font-weight: 600; padding: 0 4px; }
#add-local-fields, #add-launch-fields, #add-url-field { display: flex; flex-direction: column; gap: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

@media (max-width: 720px) {
  .page { padding: 20px 16px 32px; }
  .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .who { align-items: flex-start; }
}
