:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #1e3a8a;
  --primary-hover: #2563eb;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #047857;
  --warning: #b45309;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.accent-bar {
  height: 4px;
  background: var(--primary);
  margin: -24px -24px 20px -24px;
  border-radius: var(--radius) var(--radius) 0 0;
}

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

/* Auth Screen */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.auth-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--surface-muted);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.auth-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

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

.auth-note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-form {
  margin-top: 18px;
  text-align: left;
}

/* Dashboard Layout */
.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

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

.project-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.date-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

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

.date-status-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grid-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 960px) {
  .grid-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.card-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.card-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.card-header-row .card-title {
  margin-bottom: 0;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  margin-bottom: 6px;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.date-input {
  width: auto;
  min-width: 170px;
  font-weight: 600;
}

.textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.6;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s, transform 0.08s;
}

.btn:active {
  transform: scale(0.99);
}

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

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

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

.btn-danger-outline:hover:not(:disabled) {
  background: #fee2e2;
}

/* Badges & Alerts */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge-neutral {
  background: var(--surface-muted);
  color: var(--text-muted);
  border-color: var(--border-light);
}

.badge-ok {
  background: #ecfdf5;
  color: var(--success);
  border-color: #a7f3d0;
}

.badge-warn {
  background: #fffbeb;
  color: var(--warning);
  border-color: #fde68a;
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: left;
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* Passages List */
.passages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.passage-item {
  border: 1px solid var(--border-light);
  background: var(--surface-muted);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.passage-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.passage-num {
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.passage-preview {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: #1e293b;
  word-break: break-word;
}

.passage-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.passage-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

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

.empty-state {
  text-align: center;
  padding: 36px 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.modal-card-sm {
  max-width: 460px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 800;
}

.modal-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary);
}

.kicker-danger {
  color: var(--danger);
}

.icon-btn {
  border: 1px solid var(--border-light);
  background: var(--surface-muted);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.cache-reminder {
  margin: 0;
  font-size: 12px;
  color: var(--warning);
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 8px 10px;
  border-radius: 6px;
}

.delete-desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: #334155;
}

.preview-box {
  padding: 10px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #475569;
  margin-bottom: 18px;
  word-break: break-word;
}

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

/* Toast */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  border: 1px solid transparent;
}

.toast-success {
  background: #ecfdf5;
  color: var(--success);
  border-color: #a7f3d0;
}

.toast-error {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}
