/* 
  ShadCN / Vercel Ultra-Minimalist Theme
  Replaces previous heavy UI with pristine Dark Mode elements
*/

:root {
  --background: #E0ECF0;
  --foreground: #333333;
  --card: #FFFFFF;
  --card-foreground: #333333;
  --primary: #C94F53;
  --primary-foreground: #FFFFFF;
  --secondary: #F4EBEA;
  --secondary-foreground: #672223;
  --muted: #EDEDED;
  --muted-foreground: #672223;
  --border: #E0ECF0;
  --input: #FFFFFF;
  --ring: #672223;
  --radius: 0.5rem;
  --danger: #C94F53;
  --danger-hover: #672223;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ── TOP NAVIGATION ── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background-color: rgba(103, 34, 35, 0.95);
  backdrop-filter: blur(12px);
}
.nav-container {
  display: flex;
  height: 3.5rem;
  align-items: center;
  padding: 0 2rem;
  max-width: 1400px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  margin-right: 2rem;
  color: #FFFFFF;
}
.brand-logo {
  width: 1.5rem;
  height: 1.5rem;
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
}
.badge {
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  margin-left: 0.3rem;
  font-weight: 600;
}
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { 
  font-size: 0.875rem; 
  color: rgba(255, 255, 255, 0.76); 
  transition: color 0.2s; 
  font-weight: 500; 
}
.nav-links a:hover, .nav-links a.active { color: #FFFFFF; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.session-identity {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.2rem);
  background: rgba(255, 255, 255, 0.82);
  min-height: 2.25rem;
}
.session-identity-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.session-identity-text strong {
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}
.session-identity-text span {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  margin-top: 0.1rem;
}
.top-nav .session-identity-text span {
  color: #5f3a3a;
}
.top-nav .badge {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.35);
  color: #672223;
}

/* ── LAYOUT & TYPOGRAPHY ── */
.main-wrapper { 
  max-width: 1400px; 
  margin: 0 auto; 
  padding: 2.5rem 2rem; 
}
.page-header { 
  display: flex; 
  align-items: flex-end; 
  justify-content: space-between; 
  margin-bottom: 1.5rem; 
}
.page-header h1 { 
  font-size: 1.875rem; 
  font-weight: 700; 
  margin: 0 0 0.25rem 0; 
  letter-spacing: -0.025em; 
}
.page-header p { 
  color: var(--muted-foreground); 
  margin: 0 0 0.2rem 0; 
  font-size: 0.875rem; 
  font-weight: 500;
}

/* ── TABLE TOOLBAR ── */
.table-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.toolbar-select {
  width: auto;
  min-width: 160px;
}

.ticket-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.ticket-summary-card {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.125rem);
  background: #FFFFFF;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ticket-summary-card span {
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.ticket-summary-card strong {
  font-size: 1.85rem;
  line-height: 1;
}

/* ── FEEDBACK MESSAGE ── */
.feedback-msg {
  font-size: 0.8rem;
  min-height: 1.25rem;
  margin: 0 0 0.75rem 0;
  color: var(--muted-foreground);
}
.feedback-msg.error { color: var(--danger); }
.feedback-msg.success { color: #4ade80; }

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(92vw, 360px);
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(103, 34, 35, 0.35);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-loader.hidden {
  display: none;
}

.page-loader-card {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.15rem);
  background: #FFFFFF;
  color: var(--foreground);
  font-size: 0.85rem;
}

.loader-spinner,
.button-spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 2px solid rgba(103, 34, 35, 0.2);
  border-top-color: #672223;
  animation: loader-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.button-spinner {
  width: 0.85rem;
  height: 0.85rem;
}

.btn.is-loading,
.button.is-loading {
  pointer-events: none;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

@keyframes loader-spin {
  to {
    transform: rotate(360deg);
  }
}
.toast {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  background: #FFFFFF;
  color: var(--foreground);
  font-size: 0.82rem;
  box-shadow: 0 10px 26px rgba(103, 34, 35, 0.12);
  animation: toast-in 0.18s ease-out;
}
.toast-success {
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(22, 101, 52, 0.18);
}
.toast-error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(153, 27, 27, 0.2);
}
.toast.hiding {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── CARDS ── */
.card, .panel, .login-panel, .hero-panel {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--card-foreground);
}
.card-header, .panel-header { 
  padding: 1.5rem; 
  display: flex; 
  flex-direction: column; 
  gap: 0.3rem; 
  border-bottom: 1px solid transparent;
}
.card-title { 
  font-size: 1rem; 
  font-weight: 600; 
  margin: 0; 
  letter-spacing: -0.01em; 
}
.card-description { 
  font-size: 0.875rem; 
  color: var(--muted-foreground); 
  margin: 0; 
}
.card-content { padding: 1.5rem; padding-top: 0; }

/* ── BUTTONS ── */
.btn, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.25rem;
  padding: 0 1rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary, .button-primary { 
  background-color: var(--primary); 
  color: var(--primary-foreground); 
}
.btn-primary:hover, .button-primary:hover { opacity: 0.9; }
.btn-secondary, .button-secondary { 
  background-color: #FFFFFF; 
  color: var(--foreground); 
  border: 1px solid #d9c8c8; 
}
.btn-secondary:hover, .button-secondary:hover { 
  background-color: #F4EBEA; 
}
.btn-ghost {
  background: #FFFFFF;
  color: var(--foreground);
  border: 1px solid #d9c8c8;
}
.btn-ghost:hover { background-color: #F4EBEA; color: var(--foreground); }
.btn-danger {
  background-color: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover { background-color: var(--danger-hover); }

/* ── TABLE ── */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th, .table td {
  text-align: left;
  padding: 0.55rem 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-compact th,
.table-compact td {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}
.table th { 
  color: #333333; 
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.table tr:hover td { background-color: rgba(255,255,255,0.02); }
.table td:last-child,
.table th:last-child { width: 1%; white-space: nowrap; text-align: right; }

/* ── TABLE ACTIONS ── */
.table-actions {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  justify-content: flex-end;
  min-height: 2.125rem;
}
td.table-actions {
  display: table-cell;
  text-align: right;
  white-space: nowrap;
}
.table-actions .btn {
  height: 1.875rem;
  padding: 0 0.625rem;
  font-size: 0.8rem;
}
td.table-actions .btn {
  margin-left: 0.375rem;
}
td.table-actions .btn:first-child {
  margin-left: 0;
}
.table-subline {
  color: #4a4a4a;
  font-size: 0.75rem;
  margin-top: 0.2rem;
}
.table .muted {
  color: #4a4a4a;
}
.table-actions .btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
}
.table-actions .btn-danger:hover {
  background: #F4EBEA;
  border-color: #e9cdcc;
  color: #672223;
}

/* ── STATUS PILLS ── */
.badge, .status-pill, .token {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.16rem 0.55rem; border-radius: 0.45rem; font-size: 0.75rem; font-weight: 500;
  border: 1px solid #ead7d5; color: #672223; background: #F4EBEA;
}
.status-pill.active { border-color: #8fce9d; color: #166534; background: #edf8ef; }
.status-pill.pending { border-color: #e5c96b; color: #854d0e; background: #fff8db; }
.status-pill.blocked { border-color: #e6aaa9; color: #991b1b; background: #fff1f1; }
.status-pill.done { border-color: #9ebee7; color: #1e3a8a; background: #eef5ff; }

/* ── PAGINATION ── */
.pagination-row {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-overlay.open {
  display: flex;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FFFFFF;
  overflow: hidden;
}
.modal-card-sm { max-width: 420px; }
.modal-card-lg { max-width: 720px; }
.modal-card-xl { max-width: 1080px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.modal-close-btn {
  height: 1.75rem;
  width: 1.75rem;
  padding: 0;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  line-height: 1;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}
.modal-kicker {
  margin: 0 0 0.2rem 0;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.modal-intro {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.125rem);
  background: #F4EBEA;
  margin-bottom: 1rem;
}
.modal-intro p,
.modal-intro strong {
  margin: 0;
}
.modal-intro p {
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}
.modal-empty {
  padding: 1rem 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── LISTS / STACKS ── */
.stack-list { display: flex; flex-direction: column; gap: 1rem; }
.stack-item {
  display: flex; 
  flex-direction: column; 
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stack-item strong { font-size: 0.875rem; font-weight: 600; }
.stack-item p { font-size: 0.875rem; color: var(--muted-foreground); margin: 0; line-height: 1.5; }

/* ── GRIDS ── */
.content-grid { display: grid; gap: 1.5rem; }
.content-grid.two-columns { grid-template-columns: 1fr 1fr; }
.filters-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.filters-grid label { display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.875rem; font-weight: 500; }
.detail-card { min-height: 200px; padding: 0.5rem 0; color: var(--muted-foreground); font-size: 0.875rem; }

/* ── FORMS / INPUTS ── */
.stack-form { display: flex; flex-direction: column; gap: 1.125rem; }
.stack-form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.875rem; font-weight: 500; }
.stack-form label.toggle-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.form-field { display: flex; flex-direction: column; gap: 0.5rem; }
.form-label { font-size: 0.875rem; font-weight: 500; color: var(--foreground); }

.input-action-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.input-action-row input { flex: 1; }

/* Select with custom chevron */
.select-wrapper { position: relative; }
.select-wrapper::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted-foreground);
  pointer-events: none;
}
.select-wrapper select { appearance: none; width: 100%; padding-right: 2rem; }

input, select, textarea {
  height: 2.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #FFFFFF;
  padding: 0 0.75rem;
  color: var(--foreground);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(212, 212, 216, 0.12);
}
textarea { height: auto; padding: 0.75rem; resize: vertical; }
select option { background-color: #FFFFFF; color: var(--foreground); }

/* ── RADIO CUSTOM ── */
.radio-group {
  display: flex;
  gap: 2rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FFFFFF;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.radio-option input[type="radio"] { display: none; }
.radio-custom {
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  border: 1.5px solid var(--muted-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.radio-custom::after {
  content: '';
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 9999px;
  background: var(--foreground);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s, transform 0.15s;
}
.radio-option input[type="radio"]:checked ~ .radio-custom {
  border-color: var(--foreground);
}
.radio-option input[type="radio"]:checked ~ .radio-custom::after {
  opacity: 1;
  transform: scale(1);
}

/* ── FILE UPLOAD CUSTOM ── */
.file-upload {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  transition: border-color 0.2s, color 0.2s;
}
.file-upload:hover { border-color: var(--ring); color: var(--foreground); }

.complaint-success-modal .modal-body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.complaint-success-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.45);
  color: #4ade80;
  background: rgba(22, 101, 52, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
}
.complaint-success-title {
  margin: 0;
  font-size: 0.93rem;
}
.complaint-success-protocol {
  width: 100%;
}
.complaint-success-protocol h2 {
  margin: 0.25rem 0 0 0;
  letter-spacing: 0.02em;
}

/* ── FORM DIVIDER ── */
.form-divider { height: 1px; background: var(--border); margin: 0.25rem 0; }

/* ── BTN BLOCK ── */
.btn-block { width: 100%; height: 2.5rem; }
.button-block { width: 100%; height: 2.5rem; }

/* ── UTILS & LEGACY FALLBACKS ── */
.app-shell { display: block; }
.sidebar { display: none; }
.content { display: block; max-width: 1400px; margin: 0 auto; padding: 2rem; }
.muted { color: var(--muted-foreground); }
.eyebrow { font-size: 0.875rem; font-weight: 500; color: var(--muted-foreground); }
h2 { font-size: 1.125rem; font-weight: 600; margin: 0; }
.panel { padding: 1.5rem; }
.auth-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.5); padding: 2rem;
}
.brand-lockup h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.5rem 0; }
.landing-shell { display: grid; gap: 1.5rem; max-width: 1400px; margin: 2rem auto; padding: 0 2rem; }

.row-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ── SUBJECT MULTI-SELECT ── */
.subject-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.required-mark {
  color: var(--danger);
  font-weight: 600;
}

.subject-multiselect {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-tag {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #F4EBEA;
  font-size: 0.75rem;
}

.chip-tag button {
  background: #FFFFFF;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.chip-tag-danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
}

.chip-action-danger,
.chip-inline-confirm button {
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  line-height: 1.2;
}

.chip-action-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.chip-inline-confirm {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  color: #fca5a5;
}

.chip-inline-confirm button:last-child {
  color: #fff;
  background: rgba(239, 68, 68, 0.9);
  border-color: rgba(239, 68, 68, 0.9);
}

.subject-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.subject-search-icon {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.subject-input-row input {
  border: 0;
  padding-left: 0;
  height: 2rem;
}

.subject-input-row input:focus {
  box-shadow: none;
}

.subject-dropdown {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FFFFFF;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}

.subject-dropdown.open {
  display: block;
}

.subject-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  background: #FFFFFF;
  color: var(--foreground);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.875rem;
}

.subject-option:last-child {
  border-bottom: none;
}

.subject-option:hover,
.subject-option.selected {
  background: #EDEDED;
}

.subject-empty {
  padding: 0.65rem 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.compact-toolbar {
  margin-top: 0.25rem;
}

.rule-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.rule-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr) auto;
  gap: 1rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.125rem);
  background: #FFFFFF;
  align-items: center;
}
.rule-list-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.rule-list-item p {
  margin: 0.25rem 0 0 0;
}
.rule-list-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 0.75rem;
}
.rule-list-metrics strong {
  display: block;
  margin-top: 0.2rem;
}

.rule-section {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.125rem);
  padding: 1rem;
  background: #FFFFFF;
}
.rule-section-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.85rem;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem;
}
.check-card,
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FFFFFF;
}
.check-card {
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.check-card:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(212, 212, 216, 0.14);
}
.check-card.selected {
  border-color: var(--ring);
  background: rgba(250, 250, 250, 0.16);
  box-shadow: 0 0 0 1px rgba(250, 250, 250, 0.2), inset 0 0 0 1px rgba(250, 250, 250, 0.15);
}
.check-card.selected strong {
  color: #fff;
}
.check-card.selected small {
  color: rgba(255, 255, 255, 0.88);
}
.check-card.disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.check-card input,
.toggle-card input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: #fafafa;
  flex-shrink: 0;
}
.check-card span,
.toggle-card span {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.check-card strong,
.toggle-card strong {
  font-size: 0.875rem;
}
.check-card small,
.toggle-card small {
  color: var(--muted-foreground);
}

.rule-preview-card {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.125rem);
  padding: 1rem;
  background: #FFFFFF;
}
.rule-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.rule-preview-header p {
  margin: 0.25rem 0 0 0;
}
.rule-preview-summary {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}
.rule-preview-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
}
.preview-person {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.015);
}
.preview-person p {
  margin: 0.2rem 0 0 0;
}

/* ── HISTORY DETAIL ── */
.detail-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.detail-section .eyebrow {
  display: block;
  margin-bottom: 0.2rem;
}
.detail-grid {
  display: grid;
  gap: 1rem;
}
.detail-card-block {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.125rem);
  padding: 1rem;
  background: #FFFFFF;
}
.detail-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.85rem;
}
.ticket-detail-hero-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.ticket-detail-hero h3 {
  margin: 0.2rem 0 0 0;
  font-size: 1.9rem;
  letter-spacing: -0.03em;
}
.ticket-detail-subline {
  margin: 0.45rem 0 0 0;
  color: var(--muted-foreground);
}
.ticket-status-panel {
  min-width: 220px;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: var(--radius);
  background: rgba(74, 222, 128, 0.08);
}
.ticket-status-panel p {
  margin: 0.25rem 0 0 0;
}
.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}
.detail-meta-grid p {
  margin: 0.2rem 0 0 0;
}
.detail-span-full {
  grid-column: 1 / -1;
}
.section-action-btn {
  margin-top: 0.85rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 1rem;
}

.field-group.required > span::after {
  content: " *";
  color: #f87171;
}

.ticket-status-editor {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.ticket-status-editor select {
  min-width: 220px;
}

.ticket-timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.ticket-timeline-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  text-align: center;
}

.ticket-timeline-badge {
  position: relative;
  z-index: 1;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  color: var(--muted-foreground);
  font-weight: 700;
}

.ticket-timeline-item.active .ticket-timeline-badge,
.ticket-timeline-item.done .ticket-timeline-badge {
  border-color: #ef4444;
  background: #ef4444;
  color: #fff;
}

.ticket-timeline-item.done .ticket-timeline-badge {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.ticket-timeline-line {
  position: absolute;
  top: 1rem;
  left: calc(50% + 1.1rem);
  width: calc(100% - 0.2rem);
  height: 1px;
  background: var(--border);
}

.ticket-timeline-line.done {
  background: #4ade80;
}

.ticket-description {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.6;
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-meta-item span {
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

.ticket-share-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.ticket-share-controls select {
  min-width: 280px;
  flex: 1 1 280px;
}

.ticket-share-controls input {
  min-width: 220px;
  flex: 1 1 240px;
}

.compact-stack-item {
  align-items: flex-start;
}

/* ── ATTACHMENT ITEM ── */
.attachment-item {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

/* ── METRICS GRID (legacy) ── */
.metrics-grid { 
  display: grid; 
  gap: 1.25rem; 
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
  margin-bottom: 2rem; 
}
.metric-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex; 
  flex-direction: column; 
  gap: 0.5rem;
}
.metric-card strong { 
  font-size: 2rem; 
  font-weight: 700; 
  margin: 0.25rem 0; 
  letter-spacing: -0.02em;
}

@media (max-width: 900px) {
  .content-grid.two-columns { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search, .toolbar-select { max-width: 100%; width: 100%; }
  .ticket-summary-grid,
  .ticket-timeline {
    grid-template-columns: 1fr 1fr;
  }
  .rule-list-item,
  .detail-meta-grid {
    grid-template-columns: 1fr;
  }
  .rule-preview-header,
  .preview-person {
    flex-direction: column;
    align-items: flex-start;
  }
  .ticket-detail-hero-top {
    flex-direction: column;
  }
  .ticket-status-panel {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .nav-container {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }
  .brand {
    margin-right: 0;
  }
  .nav-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
  }
  .nav-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
  .ticket-summary-grid,
  .ticket-timeline {
    grid-template-columns: 1fr;
  }
  .ticket-status-editor {
    flex-direction: column;
    align-items: stretch;
  }
  .ticket-timeline-line {
    display: none;
  }
  .btn,
  .button {
    height: 2.5rem;
    padding: 0 1.1rem;
  }
  .table {
    display: block;
  }
  .table thead {
    display: none;
  }
  .table tbody {
    display: grid;
    gap: 0.7rem;
  }
  .table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
  }
  .table td {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.68rem 0.82rem;
    border-bottom: 1px solid var(--border);
    width: 100%;
    text-align: left;
    white-space: normal;
  }
  .table td:last-child {
    border-bottom: none;
    width: 100%;
    text-align: left;
  }
  td.table-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
  }
  td.table-actions .btn {
    margin-left: 0;
  }
  .input-action-row {
    flex-direction: column;
    align-items: stretch;
  }
  .toast-stack {
    left: 0.8rem;
    right: 0.8rem;
    width: auto;
  }
}

@media (max-width: 640px) {
  .nav-links { gap: 0.75rem; overflow-x: auto; }
  .nav-links a { white-space: nowrap; font-size: 0.8rem; }
  .session-identity { display: none; }
  .main-wrapper { padding: 1.5rem 1rem; }
  .nav-container { padding: 0 1rem; }
  .metrics-grid { grid-template-columns: 1fr; }
  .modal-footer {
    flex-direction: column-reverse;
  }
  .modal-footer .btn {
    width: 100%;
  }
  .rule-list-metrics,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
