:root {
  --brand-50: #f2ebff;
  --brand-100: #e3d6ff;
  --brand-500: #5421d2;
  --brand-600: #3a0ca3;
  --brand-700: #2e0986;
  --brand-800: #220569;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f7fb;
  --ok: #166534;
  --ok-bg: #ecfdf3;
  --bad: #991b1b;
  --bad-bg: #fef2f2;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 18px 50px rgb(24 1 75 / 0.18);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.45 "Segoe UI", Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
h2 { font-size: 1rem; margin: 1rem 0 0.3rem; }

.shell { min-height: 100%; display: flex; }
.sidebar {
  width: 248px; flex: none; background: white; border-right: 1px solid rgb(229 231 235 / 0.85);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { height: 64px; display: flex; align-items: center; padding: 0 1.1rem; border-bottom: 1px solid #f3f4f6; }
.brand img { height: 28px; width: auto; }
.nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.75rem; }
.nav a { color: #374151; border-radius: 8px; padding: 0.55rem 0.7rem; font-weight: 650; }
.nav a:hover, .nav a.active { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }
.sidebar-menu { flex: 1; display: flex; flex-direction: column; }
.nav-toggle { display: none; }
.sidebar-foot { margin-top: auto; padding: 0.9rem 1rem 1.1rem; border-top: 1px solid #f3f4f6; color: var(--muted); font-size: 0.82rem; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.4rem; background: rgb(255 255 255 / 0.86); border-bottom: 1px solid rgb(229 231 235 / 0.7);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 4;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
main.page { padding: 1.15rem 1.4rem 2.4rem; max-width: 1080px; }
.foot { margin-top: auto; border-top: 1px solid rgb(229 231 235 / 0.7); color: #9ca3af; font-size: 11px; padding: 0.45rem 1.4rem; display: flex; justify-content: space-between; }

.card { background: white; border: 1px solid rgb(229 231 235 / 0.9); border-radius: 12px; box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 0.9rem; }
.stats { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.stat { flex: 1; min-width: 120px; }
.stat b { display: block; font-size: 1.35rem; color: var(--brand-700); }
.note { color: var(--muted); font-size: 0.92rem; }
.banner { padding: 0.6rem 0.75rem; border-radius: 8px; margin-bottom: 0.8rem; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.03em; text-transform: uppercase; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; }
.badge { display: inline-block; padding: 0.08rem 0.45rem; border-radius: 999px; background: var(--brand-50); color: var(--brand-800); font-size: 0.78rem; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 650; }
.checks label, .choice { font-weight: 550; display: flex; gap: 0.45rem; align-items: center; margin: 0.35rem 0; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 0.5rem 0.6rem; background: white;
}
textarea { min-height: 6.5rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgb(58 12 163 / 0.18); }
.btn, button {
  background: var(--brand-600); color: white; border: 0; border-radius: 8px; padding: 0.48rem 0.85rem;
  font-weight: 650; cursor: pointer; box-shadow: var(--shadow);
}
button:hover { background: var(--brand-700); }
button.secondary { background: white; color: #374151; border: 1px solid #d1d5db; box-shadow: none; }
button.ghost { background: transparent; color: #4b5563; box-shadow: none; padding: 0.3rem 0.45rem; }
button.danger { background: var(--bad); }
button.small { padding: 0.28rem 0.55rem; font-size: 0.82rem; box-shadow: none; }

.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: linear-gradient(135deg, #f9fafb, white 42%, #f2ebff); }
.login-card { width: min(440px, 100%); background: white; border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid rgb(229 231 235 / 0.8); padding: 1.6rem 1.5rem 1.2rem; }
.login-card img { display: block; height: 40px; margin: 0 auto 0.7rem; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin: 0; }

dialog.modal { width: min(760px, calc(100% - 2rem)); max-height: min(90vh, 880px); border: 0; padding: 0; border-radius: 16px; box-shadow: var(--shadow-lg); color: var(--ink); }
dialog.modal::backdrop { background: rgb(17 24 39 / 0.5); backdrop-filter: blur(4px); }
.modal-head, .modal-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; padding: 0.95rem 1.15rem; }
.modal-head { border-bottom: 1px solid #f3f4f6; }
.modal-foot { border-top: 1px solid #f3f4f6; justify-content: flex-end; }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-head p, .modal-head .note { margin: 0.2rem 0 0; }
.modal-body { padding: 0.2rem 1.15rem 1rem; overflow: auto; max-height: 64vh; }
.icon-x { width: 2rem; height: 2rem; border: 0; background: transparent; color: #6b7280; font-size: 1.3rem; line-height: 1; cursor: pointer; border-radius: 8px; box-shadow: none; padding: 0; }
.icon-x:hover { background: #f3f4f6; color: var(--ink); }

@media (max-width: 840px) {
  .shell { display: block; }
  .sidebar {
    width: auto; height: auto; position: sticky; top: 0; z-index: 10;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { height: 56px; justify-content: space-between; border-bottom: 0; padding-right: 0.6rem; }
  .nav-toggle {
    display: flex; align-items: center; justify-content: center; width: 2.6rem; height: 2.6rem; padding: 0;
    background: transparent; color: #374151; border-radius: 8px; box-shadow: none;
  }
  .nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: var(--brand-50); color: var(--brand-700); }
  .nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
    display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; position: relative;
    transition: transform 0.18s ease, background 0.18s ease;
  }
  .nav-toggle span::before, .nav-toggle span::after { content: ""; position: absolute; left: 0; }
  .nav-toggle span::before { top: -6px; }
  .nav-toggle span::after { top: 6px; }
  .nav-toggle[aria-expanded="true"] span { background: transparent; }
  .nav-toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }
  .sidebar-menu {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: white; border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 56px); overflow: auto;
  }
  .sidebar.open .sidebar-menu { display: flex; }
  .nav { padding: 0.5rem 0.75rem; }
  .nav a { padding: 0.75rem 0.8rem; font-size: 1rem; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
  .topbar { position: static; min-height: 0; padding: 0.9rem 1rem; flex-wrap: wrap; }
  main.page { padding: 1rem 1rem 2rem; }
  .foot { padding: 0.45rem 1rem; }
}

