:root {
  --bg: #eef2f5;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --ink: #17212b;
  --muted: #5d6975;
  --line: #d8e0e8;
  --line-strong: #bec9d4;
  --accent: #156f67;
  --accent-strong: #0f5751;
  --accent-soft: rgba(21, 111, 103, 0.08);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --shadow: 0 10px 28px rgba(18, 31, 44, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(238, 242, 245, 0.92)),
    radial-gradient(circle at top right, rgba(21, 111, 103, 0.08), transparent 24rem),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  padding: 30px 18px 22px;
  background:
    linear-gradient(180deg, rgba(17, 25, 34, 0.98), rgba(29, 39, 52, 0.96)),
    linear-gradient(160deg, #0f2f32, #17384f);
  color: #edf4fb;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-card {
  display: none;
}

.sidebar-toolbar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.025));
  border-color: rgba(237, 244, 251, 0.1);
  box-shadow: none;
}

.sidebar-toolbar h2 {
  font-size: 16px;
  color: #f3f8fd;
  letter-spacing: 0.04em;
}

.sidebar-toolbar p {
  color: rgba(237, 244, 251, 0.66);
}

.sidebar-toolbar .toolbar-actions {
  width: 100%;
  align-items: stretch;
}

.sidebar-toolbar .pill {
  width: 100%;
  justify-content: center;
  background: rgba(21, 111, 103, 0.28);
  border: 1px solid rgba(138, 224, 216, 0.16);
  color: #e3fbf7;
}

.sidebar-toolbar .ghost {
  flex: 1 1 100%;
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(237, 244, 251, 0.12);
  color: #edf4fb;
}

.sidebar-toolbar .ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-toolbar .ghost.danger {
  color: #ffd9d4;
  border-color: rgba(255, 217, 212, 0.14);
  background: rgba(180, 35, 24, 0.16);
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}

.sidebar-version {
  margin-top: auto;
  padding-top: 10px;
  font-size: 11px;
  color: rgba(237, 244, 251, 0.54);
  letter-spacing: 0.04em;
}

.nav-item,
.subnav-item {
  width: 100%;
  border: 1px solid rgba(237, 244, 251, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-item:hover,
.subnav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active,
.subnav-item.is-active {
  background: rgba(21, 111, 103, 0.34);
  border-color: rgba(138, 224, 216, 0.18);
}

.subnav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: -2px;
  padding-left: 12px;
}

.subnav.is-collapsed {
  display: none;
}

.subnav-item {
  font-size: 13px;
  padding: 10px 12px;
}

.sidebar-status-zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-status-head {
  padding: 0 4px;
}

.sidebar-status-head h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.15;
  color: #f3f8fd;
}

.sidebar-status-head p {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(237, 244, 251, 0.62);
}

.workspace {
  padding: 18px 18px 20px;
}

.dashboard > .toolbar.panel.panel-compact {
  display: none;
}

.dashboard {
  font-size: 13px;
}

.dashboard .panel {
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 18px;
}

.dashboard .panel-compact {
  padding: 10px 12px;
}

.dashboard .panel-head {
  margin-bottom: 10px;
}

.dashboard .panel-head h2 {
  font-size: 20px;
}

.dashboard .panel-head h3 {
  font-size: 17px;
}

.dashboard .panel-head h4,
.dashboard .card-head h4 {
  font-size: 14px;
}

.dashboard .panel-head p,
.dashboard .card-head p,
.dashboard label span,
.dashboard .muted,
.dashboard .summary-chip span,
.dashboard .command-item-meta,
.dashboard .record-item p,
.dashboard .audio-file-item p {
  font-size: 11px;
  line-height: 1.4;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(23, 33, 43, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.panel-compact {
  padding: 14px 16px;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head h2,
.panel-head h3,
.panel-head h4,
.panel-head h5,
.card-head h4,
.card-head h5 {
  margin: 0;
}

.panel-head p,
.card-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-panel {
  width: min(100%, 360px);
  max-width: 360px;
  margin: 44px auto;
  padding: 24px 22px 18px;
  border-radius: 22px;
  border: 1px solid rgba(23, 33, 43, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 253, 0.98));
  box-shadow: 0 18px 44px rgba(18, 31, 44, 0.08);
  position: relative;
  overflow: hidden;
}

.auth-panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, rgba(21, 111, 103, 0.9), rgba(58, 117, 173, 0.72));
}

.auth-kicker {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.2;
  text-align: center;
}


.auth-head {
  display: none;
}



.auth-head p {
  display: none;
}

.auth-meta {
  display: none;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(21, 111, 103, 0.08);
  border: 1px solid rgba(21, 111, 103, 0.12);
  color: var(--accent-strong);
  font-size: 11px;
  line-height: 1;
}

.login-form,
.control-grid,
.inline-form,
.config-card,
.audio-library-list,
.record-list {
  display: grid;
  gap: 10px;
}

.login-form {
  width: 100%;
  max-width: 100%;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffdfa;
  color: var(--ink);
}

.dashboard input,
.dashboard select,
.dashboard textarea {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

textarea {
  resize: vertical;
}

.password-row {
  position: relative;
  display: block;
}

.primary,
.ghost {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
}

.dashboard .primary,
.dashboard .ghost {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
}

.compact {
  padding: 10px 12px;
  white-space: nowrap;
}

.dashboard .compact {
  padding: 7px 10px;
}

.wide {
  width: 100%;
}

#loginForm label > span {
  display: none;
}

#loginForm input {
  min-height: 38px;
  border-radius: 11px;
  padding: 7px 11px;
  background: #fcfdff;
  font-size: 14px;
}

#loginPasswordInput {
  padding-right: 42px;
}

#toggleLoginPasswordBtn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 8px;
  background: #fcfdff;
  border-color: transparent;
  box-shadow: none;
  font-size: 0;
}

#toggleLoginPasswordBtn::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 9px;
  border: 1.6px solid #6c5949;
  border-radius: 12px / 9px;
  transform: translate(-50%, -50%);
}

#toggleLoginPasswordBtn::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: #6c5949;
  transform: translate(-50%, -50%);
}

#toggleLoginPasswordBtn.is-visible::after {
  background: var(--accent);
}

#toggleLoginPasswordBtn:hover {
  background: #f3f7fb;
}

#loginForm .primary.wide {
  min-height: 38px;
  min-width: 120px;
  margin: 0 auto;
  padding: 0 18px;
  font-size: 16px;
  letter-spacing: 0;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: #f6efe3;
  border-color: var(--line);
  color: var(--ink);
}

.ghost:hover {
  background: #f1e6d6;
}

.ghost.danger {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.22);
  background: rgba(180, 35, 24, 0.05);
}

.message {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.4;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 251, 253, 0.98));
  border-color: rgba(23, 33, 43, 0.08);
}

.sidebar .sidebar-toolbar.toolbar.panel {
  background:
    linear-gradient(180deg, rgba(19, 43, 50, 0.96), rgba(16, 31, 45, 0.96));
  border-color: rgba(138, 224, 216, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 12px 12px 10px;
  gap: 8px;
}

.sidebar .sidebar-toolbar h2 {
  margin: 0;
  color: #f3f8fd;
  font-size: 15px;
  line-height: 1.15;
}

.sidebar .sidebar-toolbar p {
  margin: 4px 0 0;
  color: rgba(237, 244, 251, 0.72);
  font-size: 11px;
  line-height: 1.35;
}

.sidebar .sidebar-toolbar .toolbar-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 6px;
}

.sidebar .sidebar-toolbar .pill {
  grid-column: 1 / -1;
  min-height: 30px;
  padding: 0 10px;
  background: rgba(87, 186, 176, 0.22);
  border: 1px solid rgba(138, 224, 216, 0.18);
  color: #e8fcf8;
  font-size: 10px;
  line-height: 1.25;
}

.sidebar .sidebar-toolbar .ghost {
  min-height: 32px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(237, 244, 251, 0.12);
  color: #edf4fb;
  font-size: 11px;
}

.sidebar .sidebar-toolbar .ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar .sidebar-toolbar .ghost.danger {
  color: #ffd9d4;
  background: rgba(180, 35, 24, 0.16);
}

.dashboard .toolbar {
  gap: 10px;
}

.toolbar h2 {
  margin: 0;
}

.toolbar-actions,
.button-row,
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.dashboard .toolbar-actions,
.dashboard .button-row,
.dashboard .detail-actions,
.dashboard .row-actions {
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.dashboard .pill {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

.pill.online {
  background: rgba(21, 111, 103, 0.1);
  color: var(--accent-strong);
}

.pill.offline {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(18, 114, 104, 0.08);
  color: var(--accent-strong);
  font-size: 13px;
}

.notice.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.12);
}

.sidebar .notice {
  margin: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(237, 244, 251, 0.1);
  color: #edf4fb;
  box-shadow: none;
}

.sidebar .notice.error {
  background: rgba(180, 35, 24, 0.2);
  border-color: rgba(255, 217, 212, 0.14);
  color: #ffd9d4;
}

.page-section {
  display: block;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dashboard .stats {
  gap: 10px;
}

.stat-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f9fbfd);
}

.dashboard .stat-card {
  padding: 12px;
  border-radius: 16px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.dashboard .stat-card strong {
  margin-top: 6px;
  font-size: 22px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.split {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  align-items: start;
}

.inline-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  table-layout: fixed;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(31, 26, 20, 0.08);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  word-break: break-word;
}

.table-value-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdfa;
  color: var(--ink);
  line-height: 1.2;
}

.dashboard .table-value-chip {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 12px;
}

.dashboard .last-login-chip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdfa;
  color: var(--ink);
  line-height: 1.2;
  box-sizing: border-box;
}

.dashboard th,
.dashboard td {
  padding: 8px 6px;
  font-size: 11px;
}

thead th {
  color: var(--muted);
  font-weight: 600;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(68px, 1fr));
  gap: 6px;
  min-width: 150px;
}

.row-actions button {
  width: 100%;
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}

.dashboard .summary-grid {
  gap: 10px;
  margin-bottom: 10px;
}

.summary-grid > .panel {
  display: flex;
  flex-direction: column;
  min-height: 48px;
  height: 100%;
  padding: 7px 10px;
}

.summary-overview-panel {
  min-height: 0;
}

.summary-strip-head {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 0;
}

.summary-strip-head > h4,
.command-history-title > h4 {
  margin: 0;
  font-size: 13px;
  line-height: 1.1;
}

.collapsible-panel {
  align-self: stretch;
}

.collapsible-head {
  margin-bottom: 0;
}

#commandHistoryPanel:not(.is-expanded) {
  min-height: 0;
}

.command-history-strip {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.summary-strip-head p,
.command-history-title p {
  display: none;
}

.collapsible-panel.is-expanded .collapsible-head {
  margin-bottom: 12px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.dashboard .detail-summary {
  gap: 8px;
}

.summary-strip-head .detail-summary,
.command-history-summary {
  align-self: center;
  align-content: center;
}

.summary-chip,
.command-item,
.record-item,
.audio-file-item {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.dashboard .summary-chip,
.dashboard .command-item,
.dashboard .record-item,
.dashboard .audio-file-item {
  padding: 10px;
  border-radius: 12px;
}

.summary-chip span,
.command-item-meta,
.record-item p,
.audio-file-item p {
  color: var(--muted);
  font-size: 12px;
}

.summary-chip strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}

.dashboard .summary-chip strong {
  margin-top: 4px;
  font-size: 14px;
}

.summary-chip-compact {
  min-height: 0;
  padding: 4px 6px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.dashboard .summary-chip.summary-chip-compact {
  padding: 4px 6px;
  border-radius: 10px;
}

.summary-chip-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.summary-chip-compact em {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.1;
  font-style: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-chip-compact span {
  font-size: 9px;
  line-height: 1.1;
}

.summary-chip-compact strong {
  margin-top: 0;
  font-size: 11px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard .summary-chip.summary-chip-compact strong {
  margin-top: 0;
  font-size: 11px;
}

.command-history-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.detail-summary > .summary-chip.summary-chip-compact,
.command-history-summary > .summary-chip.summary-chip-compact {
  min-height: 56px;
  height: 56px;
}

.command-strip-chip {
  min-width: 0;
}

.command-history-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

#commandHistoryPanel:not(.is-expanded) .command-history-actions {
  justify-content: flex-end;
  align-content: center;
}

#commandHistoryPanel:not(.is-expanded) .command-history-actions .ghost.compact {
  min-height: 26px;
  padding: 5px 8px;
  font-size: 10px;
}

.command-history-actions .ghost.compact[aria-pressed="true"] {
  background: rgba(21, 111, 103, 0.12);
  border-color: rgba(21, 111, 103, 0.22);
  color: var(--accent-strong);
}

.command-history-list {
  display: grid;
  gap: 8px;
}

.command-compact {
  display: grid;
  gap: 8px;
}

.command-summary-card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fcfdff, #f6f9fc);
}

.command-summary-top,
.command-item-head,
.command-item-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.command-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.command-summary-top strong {
  display: block;
  font-size: 14px;
}

.command-summary-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.command-summary-message {
  margin-top: 8px;
  color: var(--danger);
  font-size: 11px;
}

.command-mini-list {
  display: grid;
  gap: 6px;
}

.command-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 0 10px;
}

.command-detail summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}

.command-detail summary::-webkit-details-marker {
  display: none;
}

.command-detail-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.command-detail-main strong {
  font-size: 12px;
}

.command-detail-main span,
.command-detail-time {
  color: var(--muted);
  font-size: 11px;
}

.command-detail-time {
  white-space: nowrap;
}

.command-detail-body {
  display: grid;
  gap: 6px;
  padding: 0 0 10px;
}

.command-detail-body div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
}

.command-detail-body span {
  color: var(--muted);
}

.command-detail-body strong {
  font-size: 11px;
  font-weight: 600;
}

.command-detail-message {
  color: var(--danger);
  font-size: 11px;
  line-height: 1.4;
}

.command-empty {
  font-size: 11px;
  color: var(--muted);
}

.command-item-message {
  margin-top: 8px;
  color: var(--danger);
  font-size: 12px;
}

.dashboard .command-item-message {
  margin-top: 6px;
  font-size: 11px;
}

.dashboard .command-summary-card,
.dashboard .command-detail {
  border-radius: 10px;
}

.config-grid {
  display: grid;
  gap: 14px;
}

.dashboard .config-grid {
  gap: 10px;
}

.config-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fafcfd);
}

.dashboard .config-card {
  padding: 12px;
  border-radius: 16px;
  gap: 8px;
}

.card-head {
  margin-bottom: 12px;
}

.dashboard .card-head {
  margin-bottom: 8px;
}

.control-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.control-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.control-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.control-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

.device-picker {
  min-width: 220px;
}

.dashboard .device-picker {
  min-width: 190px;
}

#quickControlForm,
#lightingForm,
#printerForm,
#ttsForm,
#networkForm,
#commandForm {
  gap: 12px;
}

#audioForm .control-grid-4 label:nth-child(n + 5):nth-child(-n + 9) {
  grid-column: span 2;
}

#audioForm .control-grid-4 label:last-child {
  grid-column: span 1;
}

#audioForm .audio-tools {
  align-items: stretch;
  gap: 8px;
}

#audioForm .audio-tools > label,
#audioForm .audio-tools .audio-tool-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  gap: 5px;
  min-height: 84px;
  align-content: start;
  grid-column: auto !important;
}

#audioForm .audio-tools > label span,
#audioForm .audio-tools .audio-tool-card span {
  font-size: 11px;
  line-height: 1.3;
}

#audioForm .audio-tools > label select,
#audioForm .audio-tools > label input,
#audioForm .audio-tools .audio-tool-card select,
#audioForm .audio-tools .audio-tool-card input {
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 11px;
}

#audioForm .audio-tools > label input[type="file"],
#audioForm .audio-tools .audio-tool-card input[type="file"] {
  padding: 6px 8px;
  line-height: 1.2;
}

.audio-preview-status {
  display: grid;
  gap: 3px;
  margin: 4px 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
}

.dashboard .audio-preview-status {
  margin: 2px 0 4px;
  padding: 7px 9px;
  border-radius: 10px;
}

.audio-preview-status strong {
  font-size: 11px;
  line-height: 1.2;
}

.audio-preview-status span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  word-break: break-all;
}

.audio-preview-status-info {
  border-color: rgba(28, 104, 164, 0.16);
  background: linear-gradient(180deg, rgba(233, 244, 255, 0.95), rgba(245, 249, 255, 0.96));
}

.audio-preview-status-success {
  border-color: rgba(21, 111, 103, 0.18);
  background: linear-gradient(180deg, rgba(232, 247, 244, 0.96), rgba(242, 251, 248, 0.98));
}

.audio-preview-status-error {
  border-color: rgba(180, 77, 68, 0.18);
  background: linear-gradient(180deg, rgba(255, 241, 239, 0.96), rgba(255, 248, 247, 0.98));
}

.audio-preview-status-muted,
.audio-preview-status-idle {
  border-color: rgba(106, 122, 133, 0.14);
  background: linear-gradient(180deg, rgba(246, 248, 250, 0.96), rgba(251, 252, 253, 0.98));
}

.sidebar .audio-preview-status {
  margin: 0;
  padding: 9px 10px;
  border-radius: 12px;
  border-color: rgba(237, 244, 251, 0.1);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
}

.sidebar .audio-preview-status strong {
  color: #f3f8fd;
}

.sidebar .audio-preview-status span {
  color: rgba(237, 244, 251, 0.68);
}

.sidebar .audio-preview-status-info {
  background: rgba(58, 117, 173, 0.18);
  border-color: rgba(150, 202, 245, 0.16);
}

.sidebar .audio-preview-status-success {
  background: rgba(21, 111, 103, 0.22);
  border-color: rgba(138, 224, 216, 0.16);
}

.sidebar .audio-preview-status-error {
  background: rgba(180, 35, 24, 0.2);
  border-color: rgba(255, 217, 212, 0.14);
}

.sidebar .audio-preview-status-muted,
.sidebar .audio-preview-status-idle {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(237, 244, 251, 0.1);
}

.audio-library {
  margin-top: 6px;
}

.dashboard .audio-library {
  margin-top: 2px;
}

.audio-library-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.audio-file-item strong,
.record-item strong {
  display: block;
  margin-bottom: 6px;
}

.record-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.record-title-line strong {
  min-width: 0;
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-status-chip {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.22);
  color: #ea580c;
  font-size: 11px;
  font-weight: 800;
}

.lottery-record-item p {
  margin: 4px 0 0;
  line-height: 1.45;
}

.audio-file-compact {
  min-height: 48px;
  padding: 6px 8px;
  border-radius: 10px;
}

.dashboard .audio-file-item.audio-file-compact {
  min-height: 48px;
  padding: 6px 8px;
  border-radius: 10px;
}

.audio-file-compact strong,
.dashboard .audio-file-item.audio-file-compact strong {
  margin-bottom: 2px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-file-compact p,
.dashboard .audio-file-item.audio-file-compact p {
  margin: 0;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.probability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.probability-note {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: rgba(244, 248, 251, 0.92);
}

.dashboard .probability-note {
  padding: 10px;
  border-radius: 12px;
}

.probability-note strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.probability-note p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.probability-advanced {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 251, 253, 0.96);
  padding: 8px 10px;
}

.dashboard .probability-advanced {
  padding: 6px 8px;
  border-radius: 12px;
}

.probability-advanced summary {
  cursor: pointer;
  list-style: none;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.probability-advanced summary::-webkit-details-marker {
  display: none;
}

.probability-advanced[open] summary {
  margin-bottom: 8px;
}

.log-box {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 16px;
  background: #13202d;
  color: #eef4fb;
  min-height: 180px;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
}

.dashboard .log-box {
  margin-top: 8px;
  padding: 10px;
  min-height: 140px;
  font-size: 11px;
}

.device-term-editor {
  display: grid;
  gap: 6px;
}

.device-term-editor select,
.device-term-editor input[type="date"],
.device-term-editor input[type="number"] {
  width: 100%;
}

.audit-log-list {
  display: grid;
  gap: 10px;
}

.audit-log-empty,
.audit-log-item {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.78);
}

.audit-log-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.audit-log-head strong {
  font-size: 14px;
}

.audit-log-head span,
.audit-log-meta,
.audit-log-data {
  font-size: 12px;
  color: #64748b;
}

.audit-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 4px;
}

.audit-log-data {
  word-break: break-all;
}

body.auth-only .sidebar {
  display: none;
}

body.auth-only .shell {
  grid-template-columns: 1fr;
}

body.auth-only .workspace {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

@media (max-width: 1280px) {
  .stats,
  .summary-grid,
  .inline-form,
  .audio-library-list,
  .record-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
    gap: 10px;
    max-height: 42vh;
    overflow: auto;
  }

  .sidebar .sidebar-toolbar.toolbar.panel {
    padding: 10px;
  }

  .main-nav,
  .subnav {
    display: grid;
    grid-template-columns: repeat(3, minmax(92px, 1fr));
    gap: 6px;
    padding-left: 0;
    margin-top: 0;
  }

  .subnav {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
  }

  .nav-item,
  .subnav-item {
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 10px;
    text-align: center;
    font-size: 12px;
  }

  .sidebar-status-zone,
  .sidebar-version {
    display: none;
  }

  .workspace {
    padding: 12px;
    min-width: 0;
  }

  .dashboard .panel {
    padding: 12px;
    border-radius: 14px;
  }

  .panel-head.split {
    display: grid;
    grid-template-columns: 1fr;
  }

  .table-wrap {
    margin: 0 -4px;
    padding: 0 4px 8px;
  }

  table {
    min-width: 760px;
  }

  .stats,
  .summary-grid,
  .summary-strip-head,
  .command-history-strip,
  .command-history-summary,
  .detail-summary,
  .inline-form,
  .control-grid,
  .control-grid-2,
  .control-grid-3,
  .control-grid-4,
  .probability-grid,
  .audio-library-list,
  .record-list {
    grid-template-columns: 1fr;
  }

  #audioForm .control-grid-4 label:nth-child(n + 5):nth-child(-n + 9),
  #audioForm .control-grid-4 label:last-child {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  body {
    min-width: 0;
  }

  .sidebar {
    max-height: 50vh;
  }

  .sidebar .sidebar-toolbar .toolbar-actions,
  .main-nav,
  .subnav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 8px;
  }

  .dashboard .panel {
    padding: 10px;
  }

  .inline-form {
    gap: 8px;
  }

  table {
    min-width: 700px;
  }

  .dashboard th,
  .dashboard td {
    padding: 7px 5px;
  }

  .row-actions {
    grid-template-columns: 1fr;
    min-width: 86px;
  }

  .row-actions button {
    min-height: 30px;
    padding: 6px 8px;
    font-size: 11px;
  }
}


.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(31, 26, 20, 0.42);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdfa;
  box-shadow: 0 24px 80px rgba(31, 26, 20, 0.25);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h3 {
  margin: 0 0 4px;
}

.modal-head p,
.modal-hint,
.modal-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.modal-status {
  min-height: 20px;
  color: var(--accent-strong);
  word-break: break-all;
}

.modal-card label {
  display: grid;
  gap: 6px;
}

.modal-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.ghost.compact {
  min-height: 32px;
  padding: 6px 10px;
}
