:root {
  --bg: #120f06;
  --panel: rgba(255, 224, 102, 0.15);
  --panel-2: rgba(255, 224, 102, 0.08);
  --text: #fff6d8;
  --muted: #e8ddb4;
  --accent: #ff3b30;
  --ok: #38d996;
  --border: rgba(255, 80, 80, 0.45);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: radial-gradient(circle at top, #2c1f02, var(--bg));
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(12, 8, 3, .84);
  backdrop-filter: blur(8px);
}
.topbar h1 { margin: 0; font-size: 1rem; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }
.status-pill {
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 9px; background: var(--panel); font-size: .75rem;
}
.status-pill.ok { border-color: rgba(56,217,150,.5); color: #b6ffe0; }

.tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 7px 12px; border-bottom: 1px solid rgba(255,255,255,.1);
  background: rgba(14, 10, 4, .75);
}
.tab {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 999px; padding: 6px 11px; font-weight: 700; font-size: .82rem; white-space: nowrap;
}
.tab.active { background: var(--accent); border-color: transparent; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 10px; }
.tab-page { display: none; }
.tab-page.active { display: block; }

.grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 10px; }
.kpi, .card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}
.kpi { padding: 8px 10px; }
.kpi small { display: block; color: var(--muted); font-size: .75rem; }
.kpi strong { font-size: 1.05rem; }
.card { padding: 10px; margin-bottom: 10px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h2, h3, h4 { margin: 0 0 8px; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
h4 { font-size: .88rem; }
.sub { color: var(--muted); font-size: .8rem; }

input, select, textarea, button, a {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 9px;
  margin-bottom: 6px;
  font-size: .84rem;
}
textarea { min-height: 64px; }
button { cursor: pointer; background: var(--accent); border: none; font-weight: 700; font-size: .82rem; }
button.danger { background: #721515; border: 1px solid #a73333; }
button.small { width: auto; margin-top: 6px; padding: 5px 9px; font-size: .78rem; }

.inline-form { display: grid; gap: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: .8rem; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,.1); }
th { color: var(--text); background: #2a200a; position: sticky; top: 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
td { color: var(--muted); vertical-align: top; }
.actions button { width: auto; margin: 0 3px 3px 0; padding: 4px 7px; font-size: .74rem; }

.note {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); padding: 8px; margin-bottom: 6px;
}
.note h4 { margin: 0 0 4px; }
.note p { margin: 0 0 4px; color: var(--muted); font-size: .8rem; }

.kanban {
  display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 8px 0 12px;
}
.lane {
  border: 1px solid var(--border); border-radius: 10px; padding: 7px; background: rgba(255,255,255,.03);
}
.lane h4 { margin: 0 0 6px; text-transform: capitalize; display: flex; justify-content: space-between; }
.lane-card {
  border: 1px solid rgba(255,255,255,.16); border-radius: 7px; padding: 6px; margin-bottom: 5px; background: rgba(255,255,255,.03);
  display: block; font-size: .8rem;
}
.lane-card small { display: block; color: var(--muted); margin-top: 3px; font-size: .74rem; }

.risk { padding: 3px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff; }
.risk.low { background: #3c7c46; }
.risk.medium { background: #b17316; }
.risk.high { background: #b83b19; }
.risk.critical { background: #8b102a; }

.charts-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.chart-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--panel-2); }
.chart-card canvas { width: 100% !important; height: 250px !important; }

.export-actions { display: grid; gap: 8px; }
.export-actions a {
  display: inline-block; text-decoration: none;
  border: 1px solid var(--border); background: var(--panel-2);
}

.rre-filters { display: grid; gap: 8px; margin-bottom: 10px; }
.prohappy-form { grid-template-columns: 1fr !important; }
.prohappy-filters { display: grid; gap: 8px; grid-template-columns: repeat(2,minmax(0,1fr)); margin-bottom: 10px; }
.prohappy-filters .filter-btn { margin-bottom: 0; }
.reminders-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
.reminder-filters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 10px; }
.filter-btn { margin-bottom: 0; background: var(--panel-2); border: 1px solid var(--border); padding: 5px 9px; font-size: .78rem; }
.filter-btn.active { background: var(--accent); border-color: transparent; }
.reminder-groups { display: grid; gap: 10px; }
.reminder-group { margin-bottom: 0; }
.status-select { min-width: 140px; margin-bottom: 0; }
.status-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill-btn {
  width: auto;
  margin: 0;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: .76rem;
  font-weight: 700;
}
.status-pill-btn.active {
  background: var(--accent);
  border-color: transparent;
}

.notif-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.notif-modal-content {
  width: min(640px, 95vw);
  max-height: 85vh;
  overflow: auto;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.notif-modal-content h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: #fff;
}
.notif-modal-content h4 {
  margin: 0 0 6px;
  font-size: .88rem;
  color: #e0e0e0;
}
.notif-modal-content .sub {
  color: #aaa;
  font-size: .82rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.notif-modal-content a {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: .85rem;
  width: auto;
  border: none;
  margin: 2px 0;
}
.notif-modal-content a:hover {
  background: #1d4ed8;
}
.notif-modal-content button {
  margin-top: 8px;
}
.notif-modal-content input {
  margin-bottom: 10px;
}

/* RRE only theme (orange/gold/black) */
#tab-overview {
  --rre-bg: linear-gradient(135deg, #111111 0%, #1f1f1f 100%);
  --rre-panel: #2a2a2a;
  --rre-panel-soft: #1b1b1b;
  --rre-text: #fef3c7;
  --rre-accent: #f59e0b;
  --rre-border: #fbbf24;
}
#tab-overview .card {
  background: var(--rre-bg);
  border: 2px solid var(--rre-border);
  color: var(--rre-text);
}
#tab-overview h2,
#tab-overview .sub { color: var(--rre-text); }
#tab-overview table {
  background: var(--rre-panel-soft);
  min-width: 980px;
}
#tab-overview th {
  background: #f59e0b;
  color: #111;
}
#tab-overview td { color: #fcd34d; }
#tab-overview input,
#tab-overview select,
#tab-overview textarea {
  background: var(--rre-panel);
  color: var(--rre-text);
  border: 1px solid var(--rre-border);
}
#tab-overview button {
  background: #f59e0b;
  color: #111;
}

/* ProHappy only theme (blue/yellow/red) */
#tab-crm {
  --ph-bg: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
  --ph-panel: #fff9c4;
  --ph-panel-soft: #fffde7;
  --ph-text: #1e293b;
  --ph-accent: #ef4444;
  --ph-border: #facc15;
}
#tab-crm .card {
  background: var(--ph-bg);
  border: 2px solid var(--ph-border);
  color: #fff;
}
#tab-crm h2,
#tab-crm h3,
#tab-crm .sub { color: #fff; }
#tab-crm .table-wrap,
#tab-crm #prohappySummary { background: transparent; }
#tab-crm table {
  background: var(--ph-panel-soft);
  border-radius: 10px;
  overflow: hidden;
  min-width: 980px;
}
#tab-crm th {
  background: #fde047;
  color: var(--ph-text);
}
#tab-crm td { color: var(--ph-text); }
#tab-crm input,
#tab-crm select,
#tab-crm textarea {
  background: var(--ph-panel-soft);
  color: var(--ph-text);
  border: 1px solid var(--ph-border);
}
#tab-crm button {
  background: var(--ph-accent);
  color: #fff;
}
#tab-crm .filter-btn,
#tab-crm #parseBriefBtn {
  background: #fde047;
  color: var(--ph-text);
  border: 1px solid var(--ph-border);
}
#tab-crm .kpi {
  background: var(--ph-panel);
  border-color: var(--ph-border);
}
#tab-crm .kpi small,
#tab-crm .kpi strong {
  color: var(--ph-text);
}
#tab-crm .risk.low { background: #16a34a; }
#tab-crm .risk.high { background: #f59e0b; }
#tab-crm .risk.critical { background: #dc2626; }

/* Reminders only theme (simple white/red, high contrast) */
#tab-reminders {
  --rm-bg: #ffffff;
  --rm-panel: #ffffff;
  --rm-text: #111111;
  --rm-accent: #dc2626;
  --rm-border: #fecaca;
}
#tab-reminders .card {
  background: var(--rm-panel);
  border: 1px solid var(--rm-border);
  color: var(--rm-text);
}
#tab-reminders h2,
#tab-reminders h3,
#tab-reminders .sub { color: #111; }
#tab-reminders table {
  background: #fff;
}
#tab-reminders th {
  background: #fee2e2;
  color: #7f1d1d;
}
#tab-reminders td { color: #111; }
#tab-reminders input,
#tab-reminders select,
#tab-reminders textarea {
  background: #fff;
  color: #111;
  border: 1px solid #fca5a5;
}
#tab-reminders button {
  background: var(--rm-accent);
  color: #fff;
}
#tab-reminders .filter-btn {
  background: #fff;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
#tab-reminders .filter-btn.active {
  background: #dc2626;
  color: #fff;
}
#tab-reminders .kpi {
  background: #fff;
  border: 1px solid #fecaca;
}
#tab-reminders .kpi small,
#tab-reminders .kpi strong { color: #111; }

/* Food Business theme aligned with Reminders */
#tab-orders {
  --fb-bg: #ffffff;
  --fb-panel: #ffffff;
  --fb-text: #111111;
  --fb-accent: #dc2626;
  --fb-border: #fecaca;
}
#tab-orders .card {
  background: var(--fb-panel);
  border: 1px solid var(--fb-border);
  color: var(--fb-text);
}
#tab-orders h2,
#tab-orders h3,
#tab-orders .sub { color: #111; }
#tab-orders table { background: #fff; }
#tab-orders th {
  background: #fee2e2;
  color: #7f1d1d;
}
#tab-orders td { color: #111; }
#tab-orders input,
#tab-orders select,
#tab-orders textarea {
  background: #fff;
  color: #111;
  border: 1px solid #fca5a5;
}
#tab-orders button {
  background: var(--fb-accent);
  color: #fff;
}
#tab-orders .kpi {
  background: #fff;
  border: 1px solid #fecaca;
}
#tab-orders .kpi small,
#tab-orders .kpi strong { color: #111; }

/* ---------- Form sections & labels ---------- */
.form-section {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.02);
}
.form-section legend {
  font-weight: 700;
  font-size: .84rem;
  padding: 0 6px;
}
.form-field {
  margin-bottom: 6px;
}
.form-field label {
  display: block;
  font-size: .74rem;
  font-weight: 600;
  margin-bottom: 2px;
  width: auto;
  border: none;
  background: transparent;
  padding: 0;
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: .03em;
  opacity: .85;
}
.form-field input,
.form-field select,
.form-field textarea {
  margin-bottom: 0;
}
.required { color: #ef4444; }
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.form-actions button {
  width: auto;
  min-width: 120px;
}

/* ---------- Order form header / edit mode ---------- */
.order-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: 8px;
}
.order-form-header.editing {
  background: rgba(59, 130, 246, .15);
  border: 1px solid rgba(59, 130, 246, .4);
}
.order-form-header.editing h3 { color: #93c5fd; }

/* ---------- Panel toggle group ---------- */
.panel-toggle-group {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.15);
}
.panel-toggle-btn {
  flex: 1;
  border-radius: 0;
  border: none;
  padding: 7px 12px;
  font-weight: 700;
  font-size: .8rem;
  transition: background .15s, color .15s;
}
.panel-toggle-btn:not(.active) {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.65);
}

/* ---------- Collapsible sections ---------- */
.collapsible-section > summary {
  cursor: pointer;
  list-style: none;
  padding: 3px 0;
  user-select: none;
  font-size: .88rem;
}
.collapsible-section > summary::-webkit-details-marker { display: none; }
.collapsible-section > summary::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 8px;
  font-size: .7rem;
  transition: transform .2s;
  vertical-align: middle;
}
.collapsible-section[open] > summary::before {
  transform: rotate(90deg);
}

/* ---------- Configuration panel ---------- */
.config-panel {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.config-group {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.02);
}
.config-group h4 {
  margin: 0 0 8px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .8;
}
.config-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  align-items: end;
}
.config-row button {
  align-self: end;
  margin-bottom: 0;
}
.config-row .form-field {
  margin-bottom: 0;
}
#tab-crm .config-group {
  border-color: rgba(250, 204, 21, .15);
  background: rgba(255, 255, 255, .03);
}
#tab-crm .config-group h4 {
  color: #fde047;
}

/* ---------- ProHappy form overrides ---------- */
#tab-crm .form-section {
  border-color: rgba(250, 204, 21, .25);
  background: rgba(255, 255, 255, .04);
}
#tab-crm .form-section legend {
  color: #fff;
}
#tab-crm .form-field label {
  color: rgba(255, 255, 255, .8);
}
#tab-crm .order-form-header.editing {
  background: rgba(250, 204, 21, .12);
  border-color: rgba(250, 204, 21, .4);
}
#tab-crm .order-form-header.editing h3 { color: #fde047; }
#tab-crm .panel-toggle-btn:not(.active) {
  background: rgba(250, 204, 21, .08);
  color: rgba(255, 255, 255, .55);
}
#tab-crm .panel-toggle-btn.active {
  background: #ef4444;
  color: #fff;
}
#tab-crm .collapsible-section > summary::before {
  color: #fde047;
}

/* ---------- Pagination ---------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  flex-wrap: wrap;
}
.pagination-top {
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 0;
}
.pagination-bottom {
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: 0;
}
.pagination-info {
  font-size: .82rem;
  color: var(--muted);
  white-space: nowrap;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pagination-page {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0 6px;
}
.pagination-controls button {
  width: auto;
  min-width: 60px;
  padding: 5px 10px;
  font-size: .78rem;
  margin: 0;
}
.pagination-controls button:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.pagination-size {
  width: auto;
  min-width: 90px;
  padding: 5px 8px;
  font-size: .78rem;
  margin: 0;
}
#tab-crm .pagination-bar {
  background: rgba(255, 249, 196, .5);
}
#tab-crm .pagination-info { color: var(--ph-text); }
#tab-crm .pagination-page { color: var(--ph-text); }
#tab-crm .pagination-controls button {
  background: #ef4444;
  color: #fff;
}
#tab-crm .pagination-controls button:disabled {
  background: #ccc;
  color: #888;
}
#tab-crm .pagination-size {
  background: var(--ph-panel-soft);
  color: var(--ph-text);
  border: 1px solid var(--ph-border);
}

/* ---------- Worker dashboard file links ---------- */
#tab-crm td a,
.table-wrap td a {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: .78rem;
  width: auto;
  border: none;
  margin: 2px 0;
  line-height: 1.4;
}
#tab-crm td a:hover,
.table-wrap td a:hover {
  background: #1d4ed8;
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-looking-for-worker { background: #fef3c7; color: #92400e; }
.status-worker-received { background: #dbeafe; color: #1e40af; }
.status-admin-received { background: #e0e7ff; color: #3730a3; }
.status-sent-to-customer { background: #d1fae5; color: #065f46; }

/* ---------- Button sizing consistency ---------- */
.actions {
  white-space: nowrap;
}
.actions button {
  width: auto;
  min-width: 0;
  padding: 3px 7px;
  font-size: .72rem;
  margin: 1px 2px;
  border-radius: 5px;
  white-space: nowrap;
}

@media (min-width: 880px) {
  .grid { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .inline-form { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .kanban { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .charts-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .rre-filters { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .prohappy-filters { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .reminder-filters { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .reminder-groups { grid-template-columns: repeat(3,minmax(0,1fr)); align-items: start; }
  .form-section { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
  .form-section legend { grid-column: 1 / -1; }
}
