﻿:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --panel: #ffffff;
  --panel-soft: #faf9f6;
  --ink: #171717;
  --muted: #5f625f;
  --line: #dedbd2;
  --line-strong: #c9c4b8;
  --brand: #111111;
  --accent: #f15a24;
  --accent-strong: #d94a18;
  --ok: #13795b;
  --warn: #9a5b00;
  --danger: #a33a2f;
  --info: #9f3510;
  --danger-soft: #fff7f7;
  --danger-line: #fecaca;
  --ok-soft: #edf8f2;
  --ok-line: #b8e1cf;
  --warn-soft: #fff7e6;
  --warn-line: #edd08a;
  --info-soft: #fff3ec;
  --info-line: #f0b294;
  --info-ink: #7c2d12;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120f;
  --panel: #1e1915;
  --panel-soft: #251f1a;
  --ink: #fff7ef;
  --muted: #cdbfb4;
  --line: #3b3129;
  --line-strong: #5a483d;
  --brand: #0d0d0d;
  --ok: #64c7a0;
  --warn: #f0b85d;
  --danger: #ff8c7a;
  --info: #f15a24;
  --danger-soft: #351d18;
  --danger-line: #7b3d31;
  --ok-soft: #142920;
  --ok-line: #315f4b;
  --warn-soft: #352616;
  --warn-line: #735126;
  --info-soft: #321b12;
  --info-line: #7b3418;
  --info-ink: #ffb28f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  background: #111111;
  color: #f7f5ee;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid #f7f5ee;
  border-radius: 50%;
  position: relative;
}

.brand-mark::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 13px;
  top: 13px;
}

.brand-title {
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  color: #c9c4b8;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8d4c9;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

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

.topbar {
  min-height: 72px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 4px;
}

.theme-switcher button {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.theme-switcher button.active {
  border-color: var(--accent);
  background: rgba(241, 90, 36, 0.16);
  color: var(--accent);
}

.page-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 22px 24px 32px;
  display: grid;
  gap: 18px;
}

.toolbar,
.auth-panel,
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  padding: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.auth-panel {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.section {
  overflow: hidden;
}

.section-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.section-title {
  margin: 0;
  font-size: 16px;
}

.section-body {
  padding: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  color: #3d3b35;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(241, 90, 36, 0.16);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 700;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: var(--panel-soft);
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}

.badge.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: var(--warn-line);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

.badge.info {
  color: var(--info);
  background: var(--info-soft);
  border-color: var(--info-line);
}

.detail-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
}

.kv {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.kv dt {
  color: var(--muted);
  font-size: 12px;
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.notice {
  border: 1px solid var(--info-line);
  background: var(--info-soft);
  color: var(--info-ink);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}

.notice.error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.notice.success {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
}

.modal-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.modal-summary {
  border: 1px solid var(--ok-line);
  border-radius: 8px;
  background: var(--ok-soft);
  color: var(--ok);
  padding: 12px;
  font-weight: 700;
}

.modal-kv {
  margin: 0;
  display: grid;
  gap: 10px;
}

.modal-kv div {
  display: grid;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.modal-kv dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.modal-kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.user-chip {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.access-state .section-body {
  display: grid;
  gap: 14px;
  max-width: 640px;
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar,
  .auth-panel,
  .grid,
  .grid.three,
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

