/* dashboard.css */
:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #10b981;
  --primary-2: #059669;
  --primary-soft: #d1fae5;
  --topbar-bg: #0f172a;
  --topbar-border: #1e293b;
  --topbar-text: #f1f5f9;
  --topbar-muted: #94a3b8;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.1);
  --radius: 10px;
  --radius-sm: 8px;
  --record-font-size: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: "Libre Franklin", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  font-feature-settings: "tnum";
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

/* App shell */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* Topbar */

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 16px;
  row-gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
}

.workbench-meta {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: center;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--topbar-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.workbench-title {
  margin: 0;
  min-width: 0;
  color: var(--topbar-text);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-self: center;
}

.topbar-actions .btn {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--topbar-text);
  box-shadow: none;
}

.topbar-actions .btn:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.24);
  color: var(--topbar-text);
}

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

.topbar-actions .btn-primary:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
}

/* Main */

.main {
  padding: 28px 32px;
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  border: 1px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.pill[data-value="released"]  { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.pill[data-value="draft"]     { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.pill[data-value="current"]   { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.pill[data-value="future"]    { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.pill[data-value="reference"] { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.pill[data-value="template"]  { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

/* Table */

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

thead th,
tbody td {
  font-size: var(--record-font-size);
}

thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--surface-2);
  white-space: nowrap;
  line-height: 1.2;
}

tbody tr {
  background: var(--surface);
  transition: background-color 120ms ease;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody td {
  line-height: 1.35;
}

tbody td:first-child {
  font-weight: 600;
  color: var(--text);
  min-width: 220px;
}

tbody td:nth-child(2),
tbody td:nth-child(5) {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

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

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.1;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

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

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

/* Drawer */

.drawer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.drawer[aria-hidden="true"] {
  opacity: 0;
}

.drawer[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  opacity: 0;
  transition: opacity 160ms ease-out;
}

.drawer[aria-hidden="false"] .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(360px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(15, 23, 42, 0.12);
  display: grid;
  grid-template-rows: auto 1fr;
  transform: translateX(100%);
  transition: transform 160ms ease-out;
}

.drawer[aria-hidden="false"] .drawer-panel {
  transform: translateX(0);
}

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

.drawer-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.drawer-close {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 6px;
  padding: 0;
  text-align: center;
  line-height: 1;
  font-size: 18px;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.drawer-close:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}

.drawer-body {
  padding: 16px;
  display: grid;
  gap: 12px;
  overflow-y: auto;
  align-content: start;
}

.drawer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Fields */

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

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.field input,
.field select {
  min-height: 36px;
}

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

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
  background: #fff;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.field input[readonly],
.field input:read-only {
  background: var(--surface-3);
  color: var(--muted);
  border-color: var(--border-strong);
  cursor: default;
}

.field input[readonly]:focus,
.field input:read-only:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--border-strong);
  background: var(--surface-3);
}

/* Responsive */

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

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .main {
    padding: 16px;
  }

  th,
  td {
    padding: 11px 12px;
  }

  tbody td:first-child {
    min-width: 180px;
  }

  .drawer-panel {
    width: min(100%, 360px);
  }
}
