:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --text: #111827;
  --text-muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #111827;
  --primary-hover: #0b1220;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warning-bg: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.08);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
  padding: 16px;
}

.sidebar,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.sidebar {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.session-status {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.tab-list {
  display: grid;
  gap: 8px;
}

.tab-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.tab-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-alt);
}

.tab-button.active {
  border-color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.main-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

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

input[type="search"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input[type="search"] {
  width: min(320px, 45vw);
}

input[type="search"]:focus,
textarea:focus,
.btn:focus {
  outline: 2px solid #c7d2fe;
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

.banner {
  border: 1px solid #fcd34d;
  background: var(--warning-bg);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
}

.banner.error {
  border-color: #fca5a5;
  background: var(--danger-bg);
}

.card {
  padding: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.pager {
  display: flex;
  gap: 8px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

tbody tr:hover {
  background: #fafafa;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface-alt);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--line-strong);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: #fff;
}

.btn-ghost {
  background: #fff;
}

.btn-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #fecaca;
}

.hidden {
  display: none !important;
}

.modal {
  border: none;
  padding: 0;
  width: min(900px, calc(100vw - 20px));
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.45);
}

.modal-sheet {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

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

.modal-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

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

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

pre {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
  padding: 10px;
  font-size: 12px;
  overflow: auto;
  max-height: 220px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

  .tab-list {
    grid-template-columns: 1fr 1fr;
  }

  .main-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
  }

  input[type="search"] {
    width: 100%;
  }
}
