:root {
  --navy: #021E45;
  --navy-dark: #011430;
  --navy-light: #072C5E;
  --secondary: #334866;
  --accent-blue: #0D52A5;
  --gold: #E6B019;
  --gold-hover: #d4a112;
  --cream: #FDFCF8;
  --surface: #FFFFFF;
  --border: rgba(2, 30, 69, 0.12);
  --border-strong: rgba(2, 30, 69, 0.22);
  --shadow-sm: 0 1px 2px rgba(2, 30, 69, 0.06);
  --shadow-md: 0 10px 28px -10px rgba(2, 30, 69, 0.14);
  --red-bg: #FEF2F2;
  --red-fg: #B91C1C;
  --red-bd: #FECACA;
  --orange-bg: #FFFBEB;
  --orange-fg: #B45309;
  --orange-bd: #FDE68A;
  --green-bg: #ECFDF5;
  --green-fg: #047857;
  --green-bd: #A7F3D0;
  --blue-bg: #EFF6FF;
  --blue-fg: #1D4ED8;
  --blue-bd: #BFDBFE;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--cream);
  color: var(--navy);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius-md);
  padding: 0.72rem 1.2rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), transform 140ms var(--ease), opacity 180ms var(--ease);
}

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

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

.btn-sm {
  padding: 0.48rem 0.9rem;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
}

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

.btn-navy {
  background: var(--navy);
  color: var(--surface);
}

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

.btn-outline {
  background: var(--surface);
  color: var(--navy);
  border-color: var(--border-strong);
}

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

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.12);
  color: var(--surface);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-ghost-light:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(155deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-light) 100%);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.2rem 2rem;
  box-shadow: 0 24px 60px rgba(1, 20, 48, 0.38);
  text-align: center;
}

.login-brand {
  margin-bottom: 1rem;
}

.login-logo {
  height: 54px;
  width: auto;
  object-fit: contain;
}

.login-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--navy);
  background: rgba(230, 176, 25, 0.22);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 0.85rem;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.25;
}

.login-subtitle {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  color: var(--secondary);
}

.login-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--navy);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(13, 82, 165, 0.14);
}

.form-error {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--red-fg);
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--navy);
  color: var(--surface);
  border-bottom: 3px solid var(--gold);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.topbar-logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

.topbar-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.topbar-sub {
  font-size: 0.75rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.role-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(230, 176, 25, 0.22);
  color: var(--gold);
  border: 1px solid rgba(230, 176, 25, 0.45);
}

/* Summary band */
.summary-band {
  background: #F4F6FA;
  border-bottom: 1px solid var(--border);
  padding: 1.15rem 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr 1fr;
  gap: 0.85rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.05rem;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--secondary);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.kpi-total {
  font-size: 0.82rem;
  color: var(--secondary);
}

.kpi-num {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 0.2rem;
}

.kpi-hint {
  font-size: 0.74rem;
  color: var(--secondary);
}

.progress-track {
  margin-top: 0.55rem;
  height: 8px;
  background: rgba(2, 30, 69, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--gold));
  border-radius: 999px;
  transition: width 300ms var(--ease);
}

.admin-toolbar {
  margin-top: 0.9rem;
  background: var(--surface);
  border: 1px solid rgba(230, 176, 25, 0.55);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.admin-toolbar-info {
  font-size: 0.84rem;
  color: var(--secondary);
}

.admin-toolbar-buttons {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* Main Content */
.main-content {
  padding-top: 1.25rem;
  padding-bottom: 3.5rem;
}

.tabs-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
  overflow-x: auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--navy);
  color: var(--surface);
}

.tab-count {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  background: rgba(2, 30, 69, 0.08);
  color: var(--navy);
}

.tab-btn.active .tab-count {
  background: rgba(230, 176, 25, 0.25);
  color: var(--gold);
}

.filters-bar {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  flex: 1 1 240px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill-btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--secondary);
  cursor: pointer;
}

.pill-btn.active {
  background: var(--navy);
  color: var(--surface);
  border-color: var(--navy);
}

.filter-selects {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-selects select {
  width: auto;
  min-width: 170px;
  font-size: 0.84rem;
  padding: 0.5rem 0.7rem;
}

/* Category sections & Cards */
.items-container {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.category-group-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid rgba(2, 30, 69, 0.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cards-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.item-card.is-open-card {
  border-color: rgba(13, 82, 165, 0.42);
  box-shadow: var(--shadow-md);
}

.item-card.status-answered {
  border-left: 4px solid #047857;
}

.item-card.status-draft {
  border-left: 4px solid #1D4ED8;
}

.item-card.status-open.prio-red {
  border-left: 4px solid #DC2626;
}

.item-header {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 1rem 1.15rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  font-family: inherit;
  color: inherit;
}

.item-header:hover {
  background: rgba(2, 30, 69, 0.02);
}

.item-header-main {
  flex: 1;
  min-width: 0;
}

.item-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.16rem 0.58rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-id {
  background: var(--navy);
  color: var(--surface);
}

.badge-prio-red {
  background: var(--red-bg);
  color: var(--red-fg);
  border-color: var(--red-bd);
}

.badge-prio-orange {
  background: var(--orange-bg);
  color: var(--orange-fg);
  border-color: var(--orange-bd);
}

.badge-prio-green {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: var(--green-bd);
}

.badge-status-open {
  background: #F1F5F9;
  color: #475569;
  border-color: #CBD5E1;
}

.badge-status-draft {
  background: var(--blue-bg);
  color: var(--blue-fg);
  border-color: var(--blue-bd);
}

.badge-status-answered {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: var(--green-bd);
}

.badge-q {
  background: rgba(230, 176, 25, 0.18);
  color: var(--navy);
}

.item-title {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
  line-height: 1.45;
}

.item-preview-answer {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--secondary);
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
}

.item-meta-line {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #64748B;
}

.item-toggle-icon {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-blue);
  white-space: nowrap;
  padding-top: 0.2rem;
}

/* Card Body / Form */
.item-body {
  border-top: 1px solid var(--border);
  padding: 1.1rem 1.15rem 1.25rem;
  background: #FAFBFD;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item-context {
  font-size: 0.84rem;
  color: var(--secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}

.schema-fields {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.8rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.radio-option.selected {
  border-color: var(--accent-blue);
  background: #EFF6FF;
  font-weight: 600;
}

.radio-option input {
  width: auto;
  margin: 0;
  accent-color: var(--navy);
}

.who-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.who-pill {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--secondary);
  cursor: pointer;
}

.who-pill.active {
  background: var(--navy);
  color: var(--surface);
  border-color: var(--navy);
}

.status-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status-choice-btn {
  flex: 1 1 160px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--secondary);
  cursor: pointer;
}

.status-choice-btn.active[data-status="open"] {
  background: #F1F5F9;
  color: var(--navy);
  border-color: #64748B;
}

.status-choice-btn.active[data-status="draft"] {
  background: var(--blue-bg);
  color: var(--blue-fg);
  border-color: var(--blue-fg);
}

.status-choice-btn.active[data-status="answered"] {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: var(--green-fg);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding-top: 0.35rem;
}

.item-actions-left,
.item-actions-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Concluded table / list */
.concluded-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.concluded-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #047857;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.concluded-desc {
  font-size: 0.9rem;
  font-weight: 500;
}

.concluded-meta {
  font-size: 0.78rem;
  color: var(--secondary);
  margin-top: 0.25rem;
}

/* Empty state */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  color: var(--secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(1, 20, 48, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(1, 20, 48, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card.modal-lg {
  max-width: 780px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--secondary);
}

.modal-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 0.5rem;
}

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

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
}

.checkbox-inline input {
  width: auto;
}

.export-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  background: #F8FAFC;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.history-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  background: #FAFBFD;
  font-size: 0.82rem;
}

.history-entry-meta {
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 80;
  background: var(--navy);
  color: var(--surface);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.1rem;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.toast.is-error {
  border-left-color: #EF4444;
  background: #7F1D1D;
}

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

@media (max-width: 600px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .topbar-sub {
    display: none;
  }
  .item-header {
    padding: 0.85rem 0.95rem;
  }
  .item-body {
    padding: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
  }
}
