/* Navigatu company admin — styles.
   Brand tokens (CLAUDE.md "Brand", logo-kit USAGE.md): indigo #3A3FD8 primary, sky #6EC1FF, ink #14172B, light sky #BFE4FF.
   Everything is sized in rem, so the browser's text-size setting and page zoom (Dynamic Type's web equivalent) scale the
   whole layout. Dark mode follows the system unless the user picks a theme in Settings (data-theme on <html>). */

:root {
  --indigo: #3a3fd8;
  --sky: #6ec1ff;
  --ink: #14172b;
  --light-sky: #bfe4ff;

  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --text: #14172b;
  --muted: #565b78;
  --border: #dde0ee;
  --border-strong: #c3c7de;
  --primary: #3a3fd8;
  --primary-hover: #2f34bd;
  --on-primary: #ffffff;
  --link: #3a3fd8;
  --focus: #1b6fe0;
  --info-bg: #e9eafd;
  --info-fg: #23288f;
  --ok-bg: #e2f5ea;
  --ok-fg: #14683d;
  --warn-bg: #fff2d3;
  --warn-fg: #7a4d00;
  --danger-bg: #fde7e4;
  --danger-fg: #a4210f;
  --danger: #c0291a;
  --on-danger: #ffffff;
  --shadow: 0 1px 2px rgba(20, 23, 43, 0.06), 0 4px 16px rgba(20, 23, 43, 0.05);
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --sidebar-w: 15.5rem;
  --font: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1020;
    --surface: #14172b;
    --surface-2: #1c2040;
    --text: #eceef8;
    --muted: #a6abc6;
    --border: #2a2f50;
    --border-strong: #3b4170;
    --primary: #5359f0;
    --primary-hover: #6a70ff;
    --link: #8fd0ff;
    --focus: #8fd0ff;
    --info-bg: #1f2457;
    --info-fg: #c9ccff;
    --ok-bg: #12332a;
    --ok-fg: #8de2b3;
    --warn-bg: #3a2c0c;
    --warn-fg: #ffd98a;
    --danger-bg: #43171a;
    --danger-fg: #ffb4ab;
    --danger: #e5483a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1020;
  --surface: #14172b;
  --surface-2: #1c2040;
  --text: #eceef8;
  --muted: #a6abc6;
  --border: #2a2f50;
  --border-strong: #3b4170;
  --primary: #5359f0;
  --primary-hover: #6a70ff;
  --link: #8fd0ff;
  --focus: #8fd0ff;
  --info-bg: #1f2457;
  --info-fg: #c9ccff;
  --ok-bg: #12332a;
  --ok-fg: #8de2b3;
  --warn-bg: #3a2c0c;
  --warn-fg: #ffd98a;
  --danger-bg: #43171a;
  --danger-fg: #ffb4ab;
  --danger: #e5483a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--link); text-underline-offset: 0.15em; }
code, .mono { font-family: var(--mono); font-size: 0.875em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--on-primary);
  padding: 0.5rem 1rem; z-index: 1000; border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- logo: light and dark variants swap by theme ---------- */
.logo { display: block; height: 1.9rem; width: auto; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 1rem 0.75rem;
  display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0.25rem 0.5rem 0.5rem; }
.sidebar .brand small { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; letter-spacing: 0.02em; }
.nav { display: flex; flex-direction: column; gap: 0.125rem; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--info-bg); color: var(--info-fg); font-weight: 650; }
.nav .icon { width: 1.15rem; height: 1.15rem; flex: none; }
.nav .nav-key { margin-left: auto; white-space: nowrap; font-size: 0.7rem; color: var(--muted); font-family: var(--mono); }
.sidebar .grow { flex: 1; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.topbar .company { font-weight: 650; }
.topbar .spacer { flex: 1; }
.main { padding: 1.5rem; max-width: 72rem; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .titles { flex: 1; min-width: 14rem; }
.page-head .subtitle { color: var(--muted); margin: 0.25rem 0 0; }
.page-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

@media (max-width: 56rem) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 86vw); transform: translateX(-102%);
    transition: transform 0.18s ease; z-index: 50; box-shadow: var(--shadow); height: 100dvh;
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10, 12, 28, 0.5); z-index: 40; }
  .topbar .menu-btn { display: inline-flex; }
  .main { padding: 1rem; }
  .topbar { padding: 0.6rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- cards, grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: 0.6rem; }
.card-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.grid > .card + .card { margin-top: 0; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .sub { color: var(--muted); font-size: 0.85rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; min-height: 2.5rem; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.danger-ghost { color: var(--danger-fg); border-color: var(--border-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 0.3rem 0.65rem; min-height: 2rem; font-size: 0.85rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"]::before {
  content: ""; width: 0.9em; height: 0.9em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn { padding: 0.4rem; min-width: 2.5rem; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.field > label, .field > .label { font-weight: 600; font-size: 0.9rem; }
.field .hint { color: var(--muted); font-size: 0.82rem; }
.field .error { color: var(--danger-fg); font-size: 0.85rem; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); min-height: 2.5rem;
}
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 5rem; resize: vertical; }
.field-row { display: flex; gap: 0.5rem; align-items: stretch; }
.field-row > .input { flex: 1; min-width: 0; }
.field-row .at { align-self: center; color: var(--muted); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; }
.check input { margin-top: 0.3rem; width: 1.05rem; height: 1.05rem; flex: none; }
.form-error { background: var(--danger-bg); color: var(--danger-fg); padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); margin-bottom: 0.9rem; font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0.4rem 0.8rem; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td .sub { color: var(--muted); font-size: 0.85rem; }
td.num, th.num { text-align: right; }
.row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 40rem) {
  .table-wrap.cards table, .table-wrap.cards thead, .table-wrap.cards tbody, .table-wrap.cards tr, .table-wrap.cards td { display: block; }
  .table-wrap.cards thead { position: absolute; left: -999px; }
  .table-wrap.cards tr { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
  .table-wrap.cards td { border: 0; padding: 0.25rem 0.9rem; }
  .table-wrap.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.8rem; }
}

/* ---------- chips, banners ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem;
  font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid transparent;
}
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); }
.chip.bad { background: var(--danger-bg); color: var(--danger-fg); }
.chip.info { background: var(--info-bg); color: var(--info-fg); }
.chip .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.banner {
  display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--info-bg); color: var(--info-fg);
}
.banner.warn { background: var(--warn-bg); color: var(--warn-fg); }
.banner.danger { background: var(--danger-bg); color: var(--danger-fg); }
.banner .icon { margin-top: 0.2rem; }
.banner .text { flex: 1; min-width: 0; }
.banner .text p { margin: 0; }
.banner .text p + p { margin-top: 0.25rem; }
/* Subscribe and Cancel side by side (the unpaid deletion window offers both) */
.banner .banner-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-start; }
.banner .btn { background: transparent; border-color: currentColor; color: inherit; }
.banner .btn.primary { background: currentColor; }
.banner .btn.primary > span { color: var(--surface); }
.notice {
  display: flex; gap: 0.7rem; padding: 0.75rem 0.9rem; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info-fg); margin: 0 0 1rem;
}
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }
.notice.bad { background: var(--danger-bg); color: var(--danger-fg); }
.notice.ok { background: var(--ok-bg); color: var(--ok-fg); }
.notice .icon { margin-top: 0.2rem; }
.notice p { margin: 0; }
.notice p + p { margin-top: 0.35rem; }

/* ---------- states ---------- */
.state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.state h3 { color: var(--text); margin-bottom: 0.35rem; }
.state .icon { width: 2rem; height: 2rem; margin-bottom: 0.5rem; }
.spinner { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--primary); animation: spin 0.8s linear infinite; margin: 0 auto 0.6rem; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius-sm); height: 1rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- progress ---------- */
.meter { height: 0.5rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 6rem; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.meter.hot > span { background: var(--danger); }
.meter.warm > span { background: #d9902a; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text);
  width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
dialog.wide { width: min(52rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(10, 12, 28, 0.55); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); }
.dlg-head { padding: 1rem 1.25rem 0.5rem; display: flex; gap: 0.5rem; align-items: flex-start; }
.dlg-head h2 { flex: 1; }
.dlg-body { padding: 0.5rem 1.25rem 1rem; overflow-y: auto; }
.dlg-foot { padding: 0.75rem 1.25rem 1rem; display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--border); }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 2000; max-width: min(26rem, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 500; }
.toast.bad { background: var(--danger); }
:root[data-theme="dark"] .toast { background: #2b315c; }

/* ---------- misc ---------- */
.copy-line { display: flex; gap: 0.4rem; align-items: center; min-width: 0; }
.copy-line code { overflow-wrap: anywhere; word-break: break-all; }
.dns-problem { margin-top: 0.4rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); }
.dns-problem .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.4rem; }
.dns-problem .pair > div { background: color-mix(in srgb, var(--surface) 70%, transparent); border-radius: var(--radius-sm); padding: 0.4rem 0.55rem; min-width: 0; }
.dns-problem .pair b { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.dns-problem code { overflow-wrap: anywhere; }
@media (max-width: 36rem) { .dns-problem .pair { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: break-word; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(22rem, 100%), 1fr)); }
.plan-card.current { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.price { font-size: 1.8rem; font-weight: 750; letter-spacing: -0.02em; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 0.25rem 0; display: flex; gap: 0.5rem; align-items: baseline; }
.list-plain li::before { content: "✓"; color: var(--ok-fg); font-weight: 700; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(26rem, 100%); }
.auth-card .logo { height: 2.2rem; margin-bottom: 1.25rem; }
.auth-card h1 { margin-bottom: 0.4rem; }
.pickrow { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.5rem 0.25rem; border-bottom: 1px solid var(--border); }
.pickrow:last-child { border-bottom: 0; }
.pickrow .meta { min-width: 0; flex: 1; }
.pickrow .meta .subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 0.55rem 0.9rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.kbd { font-family: var(--mono); font-size: 0.8rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.35rem; background: var(--surface-2); }
.offline-pill { background: var(--warn-bg); color: var(--warn-fg); }
