:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-muted: #f3f3f3;
  --text: #1a1c1c;
  --muted: #5b403d;
  --border: #e8e8e8;
  --brand: #b71c1c;
  --brand-dark: #91000a;
  --brand-soft: #ffdad6;
  --gold: #735c00;
  --gold-soft: #fff4cf;
  --ink: #2f3131;
  --ok: #2f7a4f;
  --warning: #735c00;
  --danger: #ba1a1a;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

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

button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  background: var(--brand-dark);
  box-shadow: 0 8px 18px rgba(183, 28, 28, 0.14);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid rgba(183, 28, 28, 0.2);
  outline-offset: 2px;
}

button.secondary {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--brand);
}

button.secondary:hover {
  border-color: var(--brand-soft);
  background: #fff3f2;
  box-shadow: none;
}

button.tonal {
  border-color: #f0dd9a;
  background: var(--gold-soft);
  color: var(--gold);
}

button.tonal:hover {
  border-color: #e9c349;
  background: #ffe088;
  box-shadow: none;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #93000a;
}

button:disabled {
  border-color: #dadada;
  background: #dadada;
  color: #5f6262;
  cursor: not-allowed;
}

button:disabled:hover,
button.secondary:disabled:hover,
button.tonal:disabled:hover,
button.danger:disabled:hover {
  background: #dadada;
  color: #5f6262;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(183, 28, 28, 0.12);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.login-panel h1 {
  margin: 0 0 24px;
  font-size: 26px;
}

.login-panel label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

.login-panel button {
  width: 100%;
  margin-top: 8px;
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--danger);
}

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.brand {
  display: grid;
  gap: 6px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.brand strong {
  color: var(--brand);
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 16px 10px;
}

.nav button {
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  box-shadow: none;
}

.nav button:hover,
.nav button.active {
  border-left-color: var(--brand);
  background: #fff3f2;
  color: var(--brand);
  box-shadow: none;
}

.nav-icon {
  width: 19px;
  height: 19px;
  object-fit: contain;
  flex-shrink: 0;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.notice-bar {
  min-height: 24px;
  padding: 10px 28px 0;
  color: var(--muted);
}

.notice-bar.error {
  color: var(--danger);
}

.content-root {
  display: grid;
  gap: 18px;
  padding: 18px 28px 32px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.metric,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric {
  padding: 18px;
}

.metric span,
.table-note {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  overflow: hidden;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

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

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.filter-panel {
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}

.filter-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.filter-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-actions button {
  min-height: 40px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  min-height: 46px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f9f9f9;
  font-size: 13px;
  font-weight: 600;
}

td.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

td.actions button {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13px;
}

.thumb {
  display: block;
  width: 72px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-muted);
}

.edit-panel {
  border-color: var(--brand-soft);
}

.edit-current-file {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.edit-actions {
  display: flex;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eeeeee;
  color: var(--muted);
  font-size: 12px;
}

.badge.ok {
  background: #e9f6ee;
  color: var(--ok);
}

.badge.warning {
  background: var(--gold-soft);
  color: var(--warning);
}

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

  .sidebar {
    position: static;
  }

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

  .nav button {
    min-width: 0;
  }

  .metrics,
  .form-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.metric {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-strong);
  border-top: 3px solid var(--gold);
}

.metric::after {
  position: absolute;
  right: -18px;
  bottom: -28px;
  width: 82px;
  height: 82px;
  border-radius: 999px;
  background: rgba(184, 138, 69, 0.14);
  content: "";
}

.metric strong {
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.ops-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.ops-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  border-bottom: 1px solid var(--border);
}

.ops-item:last-child {
  border-bottom: 0;
}

.ops-title {
  font-weight: 700;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
}

.button-icon {
  width: 17px;
  height: 17px;
  object-fit: contain;
  flex-shrink: 0;
  pointer-events: none;
}

.audio-preview {
  width: 180px;
  max-width: 100%;
  height: 34px;
}

.admin-empty-title {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
