/* HeyDui Admin Panel (80/20) — Soft Tactile Cozy Tokens (WCAG 2.1 AA) */
:root {
  color-scheme: light dark;
  --font-display: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-xs: 12px;
  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  /* Light mode (Cloud) */
  --bg-canvas: #F4F6FB;
  --bg-surface: #FFFFFF;
  --bg-surface-alt: #EAEFF8;
  --bg-elevated: #FFFFFF;
  --bg-scrim: rgba(15, 18, 27, 0.48);
  --border-subtle: #DCE3F0;
  --border-strong: #6A7794;
  --text-primary: #151B2B;
  --text-secondary: #46516B;
  --text-muted: #58647E;
  --glass-bg: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(21, 27, 43, 0.09);

  /* Accents (Dui & Luna) */
  --accent-primary: #B84C14;
  --accent-primary-hover: #9C3E0E;
  --on-accent: #FFFFFF;
  --accent-soft: #FFF0E6;
  --accent-text: #96390C;
  --accent-secondary: #0F766E;
  --accent-secondary-soft: #E6F7F5;
  --accent-secondary-text: #0B5953;
  --luna-accent: #564BC9;
  --luna-soft: #EEEBFF;
  --luna-text: #3E34A3;
  --focus-ring: #B84C14;

  /* Semantic */
  --success-bg: #E9F8F2;
  --success-border: #167A5B;
  --success-text: #105C44;
  --warning-bg: #FEF6E4;
  --warning-border: #B2640A;
  --warning-text: #7A4206;
  --danger-bg: #FDF0F2;
  --danger-border: #C53030;
  --danger-text: #A61B29;
  --crisis-btn: #B91C1C;
  --crisis-on-btn: #FFFFFF;

  --shadow-soft-sm: 0 4px 12px -2px rgba(21, 27, 43, 0.06), 0 1px 3px rgba(21, 27, 43, 0.04);
  --shadow-soft-md: 0 10px 26px -6px rgba(21, 27, 43, 0.09), 0 2px 6px rgba(21, 27, 43, 0.04);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #0F121B;
  --bg-surface: #181D2B;
  --bg-surface-alt: #22293C;
  --bg-elevated: #1E2436;
  --bg-scrim: rgba(6, 8, 14, 0.72);
  --border-subtle: #2A3248;
  --border-strong: #7E8CAE;
  --text-primary: #F2F5FC;
  --text-secondary: #BDC7DF;
  --text-muted: #9AA8C7;
  --glass-bg: rgba(24, 29, 43, 0.86);
  --glass-border: rgba(214, 224, 255, 0.12);

  --accent-primary: #FFA97A;
  --accent-primary-hover: #FFBE99;
  --on-accent: #1F1008;
  --accent-soft: #362219;
  --accent-text: #FFC9AB;
  --accent-secondary: #5EEAD4;
  --accent-secondary-soft: #132F30;
  --accent-secondary-text: #99F6E4;
  --luna-accent: #B0A8FF;
  --luna-soft: #262348;
  --luna-text: #DBD6FF;
  --focus-ring: #FFA97A;

  --success-bg: #122C2A;
  --success-border: #4ADEB0;
  --success-text: #99F4D6;
  --warning-bg: #302516;
  --warning-border: #F0B045;
  --warning-text: #FCE1A6;
  --danger-bg: #301822;
  --danger-border: #F47181;
  --danger-text: #FFB3BC;
  --crisis-btn: #F47181;
  --crisis-on-btn: #21080E;

  --shadow-soft-sm: 0 4px 14px -2px rgba(0, 0, 0, 0.28);
  --shadow-soft-md: 0 12px 28px -6px rgba(0, 0, 0, 0.38);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-top: 0;
}

p {
  margin-top: 0;
  margin-bottom: 0.85rem;
  color: var(--text-secondary);
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

code {
  font-size: 0.85em;
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

:focus-visible {
  outline: 2.5px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 8px;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-border);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--text-primary);
}

.brand-badge {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--luna-soft);
  color: var(--luna-text);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.main-container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  flex: 1 0 auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--accent-primary);
  color: var(--on-accent);
}

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

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-soft-sm);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.btn-danger {
  background: var(--crisis-btn);
  color: var(--crisis-on-btn);
}

.btn-danger-outline {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

/* Cards & Surfaces */
.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  box-shadow: var(--shadow-soft-sm);
  margin-bottom: 1.25rem;
}

.surface-card--elevated {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft-md);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-head h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0;
}

/* Auth Gate */
.auth-card {
  max-width: 560px;
  margin: 1.25rem auto;
}

.gsi-mount {
  min-height: 48px;
  display: flex;
  align-items: center;
  margin: 0.85rem 0;
}

/* Callouts */
.callout {
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-title {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.callout--info {
  background: var(--accent-secondary-soft);
  border-color: var(--accent-secondary);
  color: var(--accent-secondary-text);
}
.callout--info p, .callout--info .callout-title { color: var(--accent-secondary-text); }

.callout--warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}
.callout--warning p, .callout--warning .callout-title { color: var(--warning-text); }

.callout--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.callout--danger p, .callout--danger .callout-title { color: var(--danger-text); }

.callout--success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}
.callout--success p, .callout--success .callout-title { color: var(--success-text); }

/* Tabs */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  box-shadow: var(--shadow-soft-sm);
  margin-bottom: 1.25rem;
}

.tab-btn {
  flex: 1 1 180px;
  min-height: 46px;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.tab-btn:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

.tab-btn[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-soft-sm);
}

.kpi-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
}

.kpi-sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

/* Kill-Switch Rows */
.switch-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
}

.switch-info {
  flex: 1 1 280px;
}

.switch-title {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.switch-desc {
  font-size: 0.84375rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.switch-btn {
  min-width: 120px;
  min-height: 46px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0 1.1rem;
}

.switch-btn[aria-checked="true"] {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.switch-btn[aria-checked="false"] {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

/* Filter Pills & Reports */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.filter-pill {
  min-height: 44px;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.84375rem;
  cursor: pointer;
}

.filter-pill[aria-pressed="true"] {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--on-accent);
}

.report-list,
.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.report-item,
.user-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  padding: 1.1rem;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.65rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.status-badge--open {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.status-badge--resolved {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-badge--dismissed {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.status-badge--tier {
  background: var(--luna-soft);
  color: var(--luna-text);
}

.snippet-box {
  margin: 0.5rem 0 0.75rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.84375rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.field-group {
  margin-bottom: 0.9rem;
}

.field-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  min-height: 46px;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
}

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

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.text-input[aria-invalid="true"],
.textarea-input[aria-invalid="true"] {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.field-error {
  display: none;
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--danger-text);
}

.field-error.is-visible {
  display: block;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.search-row .text-input {
  flex: 1 1 260px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.details-box {
  margin-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
}

.details-box summary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Native Confirm Dialog */
.confirm-dialog {
  width: min(460px, calc(100vw - 2rem));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft-md);
}

.confirm-dialog::backdrop {
  background: var(--bg-scrim);
  backdrop-filter: blur(4px);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.empty-state {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 600px) {
  .surface-card {
    padding: 1.1rem;
  }

  .brand-badge {
    display: none;
  }
}
