:root {
  --bg: #faf5ea;
  --surface: #fffdf7;
  --surface-soft: #faf5ea;
  --text: #5b4a35;
  --muted: #7d6b53;
  --line: #efe8da;
  --primary: #ab8355;
  --primary-hover: #bd9366;
  --primary-soft: #f7efe0;
  --warning: #f28100;
  --danger: #f80718;
  --success: #28a800;
  --sidebar: #fdfaf4;
  --sidebar-line: #ece4d4;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow: 0 4px 10px rgba(120, 96, 62, 0.07);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Muli", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #f7efe0 0, transparent 28%),
    radial-gradient(circle at 90% 5%, #efe8da 0, transparent 35%),
    var(--bg);
  display: flex;
  overflow: hidden;
}

.app {
  width: 100%;
  display: flex;
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

.login-view {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(460px, 100%);
  background: rgba(253, 248, 238, 0.95);
  
  border: 1px solid rgba(150, 126, 92, 0.187);
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(120, 96, 62, 0.098), inset 0 1px 0 rgba(255, 250, 240, 0.55);
  padding: 20px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 14px;
  font-size: 14px;
}

.field.light,
.select.light,
.textarea.light {
  color: var(--text);
  background-color: rgba(253, 248, 238, 0.93);
  
  border-color: rgba(150, 126, 92, 0.187);
}

.sidebar {
  width: 288px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #5b4a35;
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform 0.25s ease;
}

.brand {
  padding: 20px 18px;
  border-bottom: 1px solid var(--sidebar-line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex: none;
  display: block;
  box-shadow: 0 6px 16px rgba(120, 96, 62, 0.22);
}

.brand-text {
  display: grid;
  line-height: 1.15;
  min-width: 0;
}

/* The sidebar brand is a lockup, not a document heading. It is a <p> so the
   page keeps exactly one <h1>, which is the route's real heading. */
.brand .brand-name {
  margin: 0;
  color: #5b4a35;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand p {
  margin-top: 4px;
  font-size: 12px;
  color: #7d6b53;
}

.nav {
  padding: 14px;
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #7d6a55;
  text-align: left;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn:hover {
  background: #f7efe0;
  color: #5b4a35;
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(189, 147, 102, 0.26), rgba(171, 131, 85, 0.3));
  color: #6b4a1a;
  border: 1px solid rgba(171, 131, 85, 0.4);
  box-shadow: 0 6px 16px rgba(120, 96, 62, 0.112);
}

.nav-divider {
  height: 1px;
  background: #ece4d4;
  margin: 16px 12px 8px 12px;
}

.nav-btn.nav-btn-danger {
  color: #b8362c;
  font-weight: 600;
  margin-top: 8px;
}

.nav-btn.nav-btn-danger:hover {
  background: #fdeceb;
  color: #a02d24;
}

.auth-panel {
  margin: auto 14px 14px;
  background: #fffdf7;
  border: 1px solid #e8dfcd;
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.auth-panel h2 {
  font-size: 12px;
  color: #5b4a35;
  font-weight: 700;
  margin-bottom: 2px;
}

.label {
  font-size: 11px;
  color: #7d6b53;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sep {
  border: 0;
  border-top: 1px solid #efe8da;
  margin: 6px 0;
}

.field,
.select,
.textarea {
  width: 100%;
  border-radius: 9px;
  border: 1px solid rgba(150, 126, 92, 0.187);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: rgba(253, 248, 238, 0.93);
  
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}

.select option {
  color: var(--text);
  background: #fdf8ee;
}

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

.field:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(171, 131, 85, 0.18);
}

.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select-native {
  position: absolute !important;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.searchable-select-input {
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.searchable-select.is-open .searchable-select-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(171, 131, 85, 0.18);
}

.searchable-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  background: rgba(253, 248, 238, 0.96);
  
  border: 1px solid rgba(150, 126, 92, 0.17);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(120, 96, 62, 0.112);
  max-height: 240px;
  overflow: auto;
  display: none;
}

.searchable-select.is-open .searchable-select-dropdown {
  display: block;
}

.searchable-select-list {
  padding: 6px;
  display: grid;
  gap: 2px;
}

.searchable-select-option,
.searchable-select-empty {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 6px 20px;
  text-align: left;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--muted);
}

.searchable-select-option {
  cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option.is-selected {
  background: rgba(171, 131, 85, 0.12);
  color: var(--primary);
}

.searchable-select-option:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.searchable-select-empty {
  color: var(--muted);
}

/* --- Date picker: popup calendar themed like the Direo dropdowns --- */
.date-picker-wrap {
  position: relative;
  display: block;
  min-width: 150px;
}

.date-picker-display {
  width: 100%;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 9px 34px 9px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: rgba(253, 248, 238, 0.8) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%237a82a6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>') no-repeat right 9px center;
  cursor: pointer;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.date-picker-display:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(171, 131, 85, 0.18);
}

.date-picker-popup {
  position: absolute;
  z-index: var(--z-dropdown);
  width: 288px;
  padding: 10px;
  box-sizing: border-box;
  background: rgba(253, 248, 238, 0.96);
  
  border: 1px solid rgba(150, 126, 92, 0.17);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(120, 96, 62, 0.112);
  font-family: inherit;
}

.date-picker-popup .dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.date-picker-popup .dp-nav {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdf8ee;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: .15s;
}

.date-picker-popup .dp-nav:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.date-picker-popup .dp-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.date-picker-popup .dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.date-picker-popup .dp-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
}

.date-picker-popup .dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.date-picker-popup .dp-empty {
  height: 30px;
}

.date-picker-popup .dp-day {
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.date-picker-popup .dp-day:hover {
  background: rgba(171, 131, 85, 0.12);
  color: var(--primary);
}

.date-picker-popup .dp-day.is-today {
  font-weight: 700;
  color: var(--primary);
}

.date-picker-popup .dp-day.is-selected {
  background: var(--primary);
  color: #fff;
}

.date-picker-popup .dp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1e9d9;
}

.date-picker-popup .dp-datetime {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.date-picker-popup .dp-date-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-picker-popup .dp-time-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.date-picker-popup .dp-hour,
.date-picker-popup .dp-min {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 18px 4px 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: #fdf8ee url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="5" viewBox="0 0 8 5" fill="none"><path d="M1 1l3 3 3-3" stroke="%237a82a6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat right 6px center;
  cursor: pointer;
}

.date-picker-popup .dp-hour:focus,
.date-picker-popup .dp-min:focus {
  border-color: var(--primary);
  outline: none;
}

.date-picker-popup .dp-colon {
  color: var(--muted);
  font-size: 12px;
}

.date-picker-popup .dp-ampm {
  display: flex;
  gap: 2px;
}

.date-picker-popup .dp-ampm-btn {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  font-family: inherit;
  color: var(--muted);
  background: #fdf8ee;
  cursor: pointer;
  transition: .15s;
}

.date-picker-popup .dp-ampm-btn.is-active {
  background: rgba(171, 131, 85, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.date-picker-popup .dp-actions {
  display: flex;
  gap: 6px;
}

.date-picker-popup .dp-today,
.date-picker-popup .dp-done {
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
}

.date-picker-popup .dp-today {
  background: transparent;
  color: var(--primary);
}

.date-picker-popup .dp-today:hover {
  background: rgba(171, 131, 85, 0.12);
}

.date-picker-popup .dp-done {
  background: var(--primary);
  color: #fff;
}

.date-picker-popup .dp-done:hover {
  background: var(--primary-hover);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(150, 126, 92, 0.212);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(189, 147, 102, 0.92), rgba(171, 131, 85, 0.96));
  border-color: rgba(150, 126, 92, 0.34);
  
  box-shadow: 0 6px 16px rgba(150, 116, 78, 0.21);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #bd9366, #ab8355);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(150, 116, 78, 0.27);
}

.btn-subtle {
  color: #6f5c43;
  background: rgba(255, 250, 240, 0.95);
  border-color: rgba(150, 126, 92, 0.187);
  
  box-shadow: 0 4px 12px rgba(120, 96, 62, 0.084);
}

.btn-subtle:hover {
  background: rgba(255, 250, 240, 0.95);
  border-color: rgba(150, 126, 92, 0.323);
  box-shadow: 0 6px 16px rgba(120, 96, 62, 0.112);
}

.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(253, 248, 238, 0.97);
  
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(150, 126, 92, 0.187);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.95);
  
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  color: #7f6238;
}

/* Desktop-visible status-bar toggle (previously unstyled UA button) */
.topbar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(150, 126, 92, 0.187);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.95);
  cursor: pointer;
  color: #7f6238;
}

.tb-ico {
  width: 17px;
  height: 17px;
  display: block;
}

.title-block h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.title-block p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid rgba(150, 126, 92, 0.17);
  font-size: 12px;
  background: rgba(255, 250, 240, 0.95);
  
  color: #4a3826;
  font-weight: 700;
}

.chip-button {
  cursor: pointer;
}

.health-popover {
  position: absolute;
  right: 18px;
  top: 58px;
  width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(150, 126, 92, 0.187);
  background: rgba(253, 248, 238, 0.96);
  
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(120, 96, 62, 0.112);
  padding: 10px;
  z-index: var(--z-popover);
}

.system-menu {
  position: absolute;
  right: 18px;
  top: 58px;
  width: min(460px, calc(100vw - 36px));
  border: 1px solid rgba(150, 126, 92, 0.187);
  background: rgba(253, 248, 238, 0.96);
  
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(120, 96, 62, 0.112);
  padding: 12px;
  z-index: var(--z-popover);
  max-height: min(70vh, 560px);
  overflow: auto;
}

.system-menu h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.system-menu hr {
  border: none;
  border-top: 1px solid #e8dfcd;
  margin: 12px 0;
}

.system-menu-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.system-menu .controls {
  gap: 6px;
}

.api-route-popover {
  position: absolute;
  right: 18px;
  top: 58px;
  width: min(460px, calc(100vw - 36px));
  border: 1px solid rgba(150, 126, 92, 0.187);
  background: rgba(253, 248, 238, 0.96);
  
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(120, 96, 62, 0.112);
  padding: 10px;
  z-index: var(--z-popover);
}

.health-popover h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.api-route-popover h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.health-popover-controls {
  margin-bottom: 8px;
}

.api-route-base {
  font-size: 12px;
  color: #5b4a35;
  margin-bottom: 8px;
  padding: 7px 8px;
  border: 1px solid #e8dfcd;
  border-radius: 8px;
  background: #fcf8f0;
  word-break: break-all;
}

.health-popover-body {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #5b4a35;
  max-height: 220px;
  overflow: auto;
}

.api-route-popover-body {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #5b4a35;
  max-height: 220px;
  overflow: auto;
}

.health-popover-row {
  border: 1px solid #e8dfcd;
  border-radius: 8px;
  padding: 7px 8px;
  display: grid;
  gap: 2px;
}

.api-route-popover-row {
  border: 1px solid #e8dfcd;
  border-radius: 8px;
  padding: 7px 8px;
  display: grid;
  gap: 2px;
}

.health-popover-row strong {
  font-size: 12px;
}

.api-route-popover-row strong {
  font-size: 12px;
}

.content {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow);
}

.kpi small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
}

.kpi span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Cards that host filter controls must not clip their dropdowns/popovers */
.card:has(.controls),
.card:has(.searchable-select),
.card:has(.date-picker-wrap) {
  overflow: visible;
}

.card-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Keep the filter row (and its open dropdown) above the listing body */
.card-head:has(.controls),
.card-head:has(.searchable-select),
.card-head:has(.date-picker-wrap) {
  position: relative;
  z-index: var(--z-controls);
}

.card-head h3 {
  font-size: 14px;
  font-weight: 800;
}

.card-body {
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.controls .field,
.controls .select,
.controls .textarea {
  color: var(--text);
  background-color: rgba(253, 248, 238, 0.93);
  
  border-color: rgba(150, 126, 92, 0.187);
  min-width: 150px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(150, 126, 92, 0.187);
  border-radius: var(--radius-md);
  background: rgba(253, 248, 238, 0.95);
  
  box-shadow: 0 6px 18px rgba(120, 96, 62, 0.07);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #f1e9d9;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: var(--z-content);
  background: #fcf8f0;
  color: #6f5c43;
  font-weight: 800;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid transparent;
}

.status.pending {
  background: #fff7ed;
  color: var(--warning);
  border-color: #fed7aa;
}

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

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

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.alert {
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid;
}

.alert.info {
  background: #f7efe0;
  color: #ab8355;
  border-color: #e5d7b8;
}

.alert.warn {
  background: #fff7ed;
  color: #b0552a;
  border-color: #fdba74;
}

.alert.success {
  background: #f0fdf4;
  color: #15803d;
  border-color: #a7f3d0;
}

.alert.error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(120, 96, 62, 0.32);
  z-index: var(--z-overlay);
}

.overlay.show {
  display: block;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(120, 96, 62, 0.44);
  padding: 24px;
}

.modal-overlay.show {
  display: grid;
  place-items: center;
}

#loginModal {
  z-index: var(--z-login-modal);
}

#idleModal {
  z-index: var(--z-idle-modal);
}

.modal {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: rgba(253, 248, 238, 0.96);
  
  border-radius: 16px;
  border: 1px solid rgba(150, 126, 92, 0.204);
  box-shadow: 0 12px 32px rgba(120, 96, 62, 0.126), inset 0 1px 0 rgba(255, 250, 240, 0.5);
}

.modal-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-body {
  padding: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.loading {
  color: #5b4a35;
  font-weight: 700;
  font-size: 13px;
}

.loading.is-refreshing::after {
  content: " Refreshing...";
  color: var(--primary);
  animation: refreshPulse 1.2s ease-in-out infinite;
}

@keyframes refreshPulse {
  0% { opacity: 0.45; }
  50% { opacity: 1; }
  100% { opacity: 0.45; }
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toast-stack {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: var(--z-toast);
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 28px));
}

.toast {
  border: 1px solid;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.info {
  background: #f7efe0;
  color: #ab8355;
  border-color: #e5d7b8;
}

.toast.success {
  background: #f0fdf4;
  color: #15803d;
  border-color: #a7f3d0;
}

.toast.error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.toast.warn {
  background: #fff7ed;
  color: #b0552a;
  border-color: #fdba74;
}

.toast.hide {
  opacity: 0;
  transform: translateY(6px);
}

/* Inline field validation (core/form-errors.js) */
.field.is-invalid,
.select.is-invalid,
textarea.is-invalid {
  border-color: #b91c1c;
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.12);
}

.field-error-msg {
  color: #b91c1c;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 4px;
}

.rows-error-msg {
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Loading spinner used by the "Loading …" states */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(150, 126, 92, 0.3);
  border-top-color: #ab8355;
  border-radius: 50%;
  vertical-align: -3px;
  margin-right: 7px;
  animation: spinner-rot 0.7s linear infinite;
}

@keyframes spinner-rot {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fdf8ee;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
  }
}

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

  .topbar {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .topbar-left {
    flex: 1;
    min-width: 150px;
  }

  .topbar-actions {
    display: none;
  }

  .topbar-actions.visible {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(253, 248, 238, 0.97);
    
    border-bottom: 1px solid var(--line);
    padding: 12px;
    gap: 8px;
    z-index: var(--z-popover);
  }

  #appLogoutBtn {
    display: inline-flex !important;
  }

  .topbar-actions.visible .chip,
  .topbar-actions.visible .btn {
    width: 100%;
    text-align: center;
  }

  .topbar-toggle {
    display: flex !important;
  }

  .system-menu {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 2px;
  }

  .content {
    padding: 12px;
  }

  .title-block h2 {
    font-size: 18px;
  }

  .controls .field,
  .controls .select,
  .controls .btn,
  .controls .textarea {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 12px;
  }
}

@media (max-width: 576px) {
  .title-block p {
    display: none;
  }

  .chip {
    width: 100%;
    text-align: center;
  }

  .topbar-actions.visible {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* Invoice Modal Styles */
.invoice-modal {
  width: min(800px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(253, 248, 238, 0.96);
  
  border-radius: 16px;
  border: 1px solid rgba(150, 126, 92, 0.204);
  box-shadow: 0 12px 32px rgba(120, 96, 62, 0.126), inset 0 1px 0 rgba(255, 250, 240, 0.5);
}

.invoice-modal .modal-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.invoice-modal .modal-body {
  padding: 14px;
}

.invoice-modal .modal-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.invoice-container {
  font-family: Arial, sans-serif;
}

.invoice-header {
  margin-bottom: 20px;
  border-bottom: 2px solid #4a3826;
  padding-bottom: 10px;
}

.invoice-header h2 {
  margin: 0 0 10px 0;
  color: #4a3826;
}

.invoice-header p {
  margin: 5px 0;
  font-size: 14px;
}

.invoice-container h3 {
  margin: 20px 0 10px 0;
  border-bottom: 1px solid #ddd;
  padding-bottom: 5px;
  font-size: 16px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}

.invoice-table th,
.invoice-table td {
  border: 1px solid #ece4d4;
  padding: 8px;
  text-align: left;
}

.invoice-table th {
  background-color: #f1e9d9;
  font-weight: bold;
}

.invoice-table tfoot td {
  font-weight: bold;
  background-color: #faf5ea;
}

.invoice-summary {
  margin-top: 20px;
  padding: 15px;
  background-color: #faf5ea;
  border-radius: 5px;
}

.invoice-summary .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.invoice-summary .balance-due {
  font-size: 1.2em;
  font-weight: bold;
  border-top: 2px solid #4a3826;
  margin-top: 10px;
  padding-top: 10px;
  color: #c94a3f;
}

.invoice-footer {
  margin-top: 30px;
  text-align: center;
  color: #6f5c43;
  font-size: 0.9em;
}

/* Order Invoice Modal Styles */
.invoice-party-details {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 15px;
  background-color: #faf5ea;
  border-radius: 8px;
}

.invoice-party-details .party-info,
.invoice-party-details .order-info {
  width: 48%;
}

.invoice-party-details h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
}

.invoice-party-details p {
  margin: 3px 0;
  font-size: 13px;
}

.invoice-totals {
  margin-top: 20px;
  padding: 15px;
  background-color: #faf5ea;
  border-radius: 5px;
  max-width: 300px;
  margin-left: auto;
}

.invoice-totals .total-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.invoice-totals .grand-total {
  font-size: 1.2em;
  font-weight: bold;
  border-top: 2px solid #4a3826;
  margin-top: 10px;
  padding-top: 10px;
  color: #c94a3f;
}

.invoice-notes {
  margin-top: 20px;
  padding: 10px;
  background-color: #fff7ed;
  border-radius: 5px;
}

/* Party Pricing Modal Styles */
.pricing-modal {
  width: min(700px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(253, 248, 238, 0.96);
  
  border-radius: 16px;
  border: 1px solid rgba(150, 126, 92, 0.204);
  box-shadow: 0 12px 32px rgba(120, 96, 62, 0.126), inset 0 1px 0 rgba(255, 250, 240, 0.5);
}

.pricing-modal .modal-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pricing-modal .modal-body {
  padding: 14px;
}

.pricing-container {
  font-family: Arial, sans-serif;
}

.pricing-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8dfcd;
}

.pricing-header h3 {
  margin: 0 0 8px 0;
  color: #4a3826;
  font-size: 18px;
}

.pricing-header p {
  margin: 0;
  color: #7d6a55;
  font-size: 13px;
}

.pricing-form {
  margin-bottom: 20px;
  padding: 15px;
  background-color: #fcf8f0;
  border-radius: 8px;
}

.pricing-list h4 {
  margin: 0 0 12px 0;
  color: #4a3826;
  font-size: 14px;
}

.pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pricing-table th,
.pricing-table td {
  border: 1px solid #e8dfcd;
  padding: 10px;
  text-align: left;
}

.pricing-table th {
  background-color: #f9f4ea;
  font-weight: bold;
  color: #6f5c43;
}

.pricing-table td {
  color: #5b4a35;
}

.no-pricing {
  padding: 20px;
  text-align: center;
  color: #7d6a55;
  background-color: #fcf8f0;
  border-radius: 8px;
  font-size: 13px;
}

/* ─── Framework alignment (ported from reference app) ───────────────────── */

/* Application layer scale (low -> high) */
:root {
  --z-content: 1;
  --z-controls: 50;
  --z-sticky: 100;
  --z-popover: 200;
  --z-overlay: 300;
  --z-sidebar: 350;
  --z-modal: 500;
  --z-login-modal: 560;
  --z-dropdown: 550;
  --z-idle-modal: 600;
  --z-toast: 700;
  --z-loading: 800;
  --z-fullscreen: 900;
}

/* Nav icons & sections */
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: 0.95;
}

/* Inline stroke icon inside buttons/badges */
.ico {
  width: 15px;
  height: 15px;
  display: block;
  flex: 0 0 auto;
}

.nav-section {
  border: 0;
  background: transparent;
  color: #7d6a55;
  text-align: left;
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  transition: all 0.15s ease;
}

.nav-section::after {
  content: "›";
  font-size: 16px;
  line-height: 1;
  color: #b09d86;
  margin-left: auto;
  transition: transform 0.15s ease;
}

.nav-section:hover {
  background: #f7efe0;
  color: #5b4a35;
}

.nav-section:hover::after {
  color: #7d6b53;
}

.nav-section.active {
  background: linear-gradient(135deg, rgba(189, 147, 102, 0.26), rgba(171, 131, 85, 0.3));
  color: #ab8355;
  border: 1px solid rgba(171, 131, 85, 0.4);
  box-shadow: 0 6px 16px rgba(120, 96, 62, 0.112);
}

.nav-section.active::after {
  color: #ab8355;
}

.nav-btn-home {
  border: 0;
  background: transparent;
  color: #5b4a35;
  text-align: left;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn-home .nav-icon {
  color: #c9a67a;
}

.nav-btn-home:hover {
  background: #f7efe0;
}

.nav-btn-home.active {
  background: linear-gradient(135deg, rgba(189, 147, 102, 0.26), rgba(171, 131, 85, 0.3));
  color: #6b4a1a;
  border: 1px solid rgba(171, 131, 85, 0.4);
  box-shadow: 0 6px 16px rgba(120, 96, 62, 0.112);
}

.nav-btn-home.active .nav-icon {
  color: #6b4a1a;
}

.sidebar-footer {
  padding: 0 14px 14px;
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.sidebar-footer .nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.panel-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.state-stamp {
  font-size: 12px;
  color: var(--muted);
}

.actions-col {
  width: 1%;
  white-space: nowrap;
}

/* --- Filter bar (desktop): compact controls in one row --- */
@media (min-width: 769px) {
  .card-head > .controls.has-filter-groups {
    flex: 1 1 100%;
    width: auto;
    max-width: 100%;
    display: flex;
    justify-content: flex-start;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    gap: 8px;
  }

  .card-head > .controls.has-filter-groups .filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .card-head > .controls.has-filter-groups .filter-group--right {
    margin-left: auto;
  }

  .card-head > .controls.has-filter-groups .filter-group + .filter-group {
    border-left: 1px solid var(--line);
    padding-left: 12px;
  }

  .card-head > .controls.has-filter-groups .label {
    font-size: 11px;
    font-weight: 700;
    align-self: center;
  }

  .card-head > .controls.has-filter-groups .field,
  .card-head > .controls.has-filter-groups .select,
  .card-head > .controls.has-filter-groups .searchable-select,
  .card-head > .controls.has-filter-groups .date-picker-wrap {
    width: auto;
    min-width: 0;
  }

  .card-head > .controls.has-filter-groups .select,
  .card-head > .controls.has-filter-groups .field {
    font-size: 12.5px;
    padding: 6px 10px;
    border-radius: 8px;
    min-height: 32px;
  }

  .card-head > .controls.has-filter-groups .select {
    min-width: 120px;
  }

  .card-head > .controls.has-filter-groups .field[type="text"] {
    min-width: 150px;
  }

  .card-head > .controls.has-filter-groups .field[type="date"] {
    min-width: 135px;
  }

  .card-head > .controls.has-filter-groups .field[type="number"] {
    min-width: 100px;
  }

  .card-head > .controls.has-filter-groups .btn,
  .card-head > .controls.has-filter-groups .dropdown-toggle {
    font-size: 12px;
    padding: 7px 12px;
    border-radius: 8px;
  }

  .card-head > .controls.has-filter-groups .inline-check {
    font-size: 12px;
    white-space: nowrap;
  }

  .card-head > .controls.has-filter-groups .searchable-select-input,
  .card-head > .controls.has-filter-groups .date-picker-display {
    font-size: 12.5px;
    padding: 6px 30px 6px 10px;
    border-radius: 8px;
    min-height: 32px;
  }

  .card-head > .controls.has-filter-groups .searchable-select-input {
    padding-right: 28px;
  }

  .card-head > .controls.has-filter-groups .date-picker-toggle {
    padding: 6px;
  }
}

/* --- Content toolbar: buttons acting on panel content sit above it --- */
.content-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.content-toolbar .btn,
.content-toolbar .dropdown-toggle {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
}

/* --- Map & Listings split panel --- */
.split-toggle {
  display: none;
  gap: 6px;
  width: fit-content;
  background: #fdf8ee;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin: 0 0 14px;
}

.split-tab {
  border: none;
  background: transparent;
  color: #6f5c43;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.15s;
}

.split-tab:hover {
  color: var(--primary, #ab8355);
}

.split-tab.is-active {
  background: var(--primary, #ab8355);
  color: #fff;
}

.map-split {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.map-split-list {
  min-width: 0;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}

.map-split-canvas {
  min-width: 0;
  position: sticky;
  top: 16px;
}

.map-split-canvas #map {
  height: 72vh;
  min-height: 480px;
}

.map-panel-card {
  background: #fdf8ee;
  border: 1px solid rgba(150, 126, 92, 0.17);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(120, 96, 62, 0.06);
  transition: box-shadow 0.15s, transform 0.15s;
}

.map-panel-card:hover {
  box-shadow: 0 10px 22px rgba(120, 96, 62, 0.1);
  transform: translateY(-1px);
}

.map-panel-card .mp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.map-panel-card .mp-name {
  font-size: 15px;
  color: #4a3826;
}

.map-panel-card .mp-meta {
  color: #7d6a55;
  font-size: 12.5px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-panel-card .mp-rating {
  color: #7d6a55;
  font-size: 12.5px;
  margin-bottom: 8px;
}

.map-panel-card .mp-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.map-panel-card .mp-actions--alt {
  border-top: 1px solid #f0e7d6;
  padding-top: 8px;
  margin-top: 8px;
}

@media (max-width: 992px) {
  .split-toggle {
    display: flex;
  }

  .map-split {
    grid-template-columns: 1fr;
  }

  .map-split-canvas {
    position: static;
  }

  .map-split-canvas #map {
    height: 56vh;
    min-height: 380px;
  }

  .map-split[data-view="list"] .map-split-canvas {
    display: none;
  }

  .map-split[data-view="map"] .map-split-list {
    display: none;
  }
}

/* --- Section view & tabs --- */
.section-intro {
  margin: 0 0 16px;
  color: var(--text-secondary, #6f5c43);
  font-size: 14px;
}

.section-view.has-tabs {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.section-tabs {
  display: flex;
  align-items: flex-end;
  height: 48px;
  box-sizing: border-box;
  padding: 0 10px;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar {
  display: none;
}

.section-tab {
  flex: 0 0 auto;
  width: 150px;
  height: 48px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-align: left;
  padding: 0 16px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.section-tab:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.section-tab.active {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--line);
  border-bottom: 3px solid var(--primary);
  font-weight: 800;
}

.section-view.has-tabs .section-view-body .panel.active > .card:first-child {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* --- Row actions (quick buttons + kebab menu) --- */
.row-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.row-actions-quick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.row-actions-quick:hover {
  background: #f9f4ea;
  border-color: #e2d8c2;
  color: var(--text);
}

.row-actions-quick:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.row-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.row-actions-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.row-actions-toggle:hover,
.row-actions.is-open .row-actions-toggle {
  background: #f9f4ea;
  border-color: #e2d8c2;
  color: var(--text);
}

.row-actions-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.row-actions-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--z-popover);
  min-width: 150px;
  padding: 6px;
  background: rgba(253, 248, 238, 0.96);
  
  border: 1px solid rgba(150, 126, 92, 0.17);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(120, 96, 62, 0.112);
  display: none;
}

.row-actions.is-open .row-actions-menu {
  display: block;
}

.row-actions-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.row-actions-item:hover {
  background: #f9f4ea;
}

.row-actions-item--danger {
  color: #e05348;
}

.row-actions-item--danger:hover {
  background: #fef2f2;
}

.row-actions-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .row-actions-toggle {
    width: 34px;
    height: 34px;
  }

  .row-actions-quick {
    padding: 5px 8px;
  }

  .row-actions-quick .row-actions-icon {
    display: none;
  }

  .controls {
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .row-actions-toggle {
    width: 32px;
    height: 32px;
  }
}

/* --- Mobile-friendly filter controls --- */
.filter-toggle {
  display: none;
}

.filter-toggle-arrow {
  font-size: 9px;
  transition: transform 0.2s ease;
}

.filter-toggle.is-open .filter-toggle-arrow {
  transform: rotate(180deg);
}

@media (max-width: 768px) {
  .card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .card-head > .controls {
    width: 100%;
    justify-content: flex-start;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Tablets: two columns fit comfortably; phones stay single column. */
  @media (min-width: 577px) {
    .card-head > .controls {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .card-head > .controls .filter-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    border-left: 0;
    padding-left: 0;
  }

  @media (min-width: 577px) {
    .card-head > .controls .filter-group {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .card-head > .controls.is-collapsed {
    display: none;
  }

  .content-toolbar {
    justify-content: flex-start;
  }

  .content-toolbar .btn,
  .content-toolbar .dropdown {
    flex: 1 1 calc(50% - 4px);
    min-height: 40px;
  }

  .content-toolbar .dropdown-toggle {
    width: 100%;
    min-height: 40px;
    justify-content: space-between;
  }

  .card-head .controls .label {
    width: 100%;
    white-space: normal;
  }

  .card-head .controls .field,
  .card-head .controls .select,
  .card-head .controls .btn,
  .card-head .controls .textarea,
  .card-head .controls .searchable-select,
  .card-head .controls .dropdown,
  .card-head .controls .date-picker-wrap {
    width: 100%;
    min-width: 0;
  }

  .card-head .controls .dropdown-toggle,
  .card-head .controls .btn {
    min-height: 40px;
  }

  .card-head .controls .dropdown-toggle {
    justify-content: space-between;
  }

  .filter-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
  }

  .date-picker-wrap {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .date-picker-display {
    min-height: 40px;
  }

  .searchable-select-input {
    min-height: 40px;
  }
}

@media (max-width: 480px) {
  .date-picker-popup {
    max-width: calc(100vw - 16px);
  }
}

/* Community moderation UI */
.rep-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: #f7efe0;
  color: #82603a;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.community-score {
  display: inline-block;
  min-width: 26px;
  padding: 2px 10px;
  border-radius: 12px;
  background: #e8f0f8;
  color: #4a7ab5;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}
.community-minor {
  color: #7d6a55;
  font-size: 12px;
}
.admin-queue li {
  margin: 2px 0;
  list-style: none;
}
.admin-queue li::before {
  content: "⚑ ";
  color: #ab8355;
}

/* ───────────────────── email links that own the whole screen ────────────────
   /verify-email and /reset-password are exclusive routes: the pre-paint script
   in template.html sets html[data-route] so the public page behind them is
   never painted, and isAuthRouteActive() stops any later view switch from
   racing them. The card below is the only visible surface while a route is
   active. Listed per route rather than with a wildcard so an unrelated
   data-route value can never blank the app. */
html[data-route="verify-email"] body > #publicView,
html[data-route="verify-email"] body > #appShell,
html[data-route="verify-email"] #loginModal,
html[data-route="verify-email"] #sidebar,
html[data-route="verify-email"] #globalMessage,
html[data-route="verify-email"] #idleModal,
html[data-route="reset-password"] body > #publicView,
html[data-route="reset-password"] body > #appShell,
html[data-route="reset-password"] #loginModal,
html[data-route="reset-password"] #sidebar,
html[data-route="reset-password"] #globalMessage,
html[data-route="reset-password"] #idleModal { display: none !important; }

.verify-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(171, 131, 85, 0.12), transparent 60%),
    var(--bg);
}

/* --muted is used for small, low-emphasis text, so it has to clear WCAG AA
   (4.5:1) against every background it lands on: #7d6b53 gives 5.04:1 on
   --surface and 4.71:1 on --bg. The previous #9c8973 was only 3.31:1. */
.verify-view {
  --verify-copy: #75634e;
}

.verify-card {
  width: 100%;
  max-width: 460px;
  padding: 36px 32px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.verify-mark {
  width: 60px;
  height: 60px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  transition: background 0.25s ease, color 0.25s ease;
}
.verify-mark svg { width: 30px; height: 30px; }

.verify-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.verify-lead {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--verify-copy);
}

.verify-detail {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--verify-copy);
}
.verify-detail:empty { margin: 0; }

.verify-actions {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
/* Standalone page: slightly larger tap targets than the in-app buttons. */
.verify-actions .btn { min-width: 150px; min-height: 42px; }

.verify-foot {
  margin: 22px 0 0;
  font-size: 12px;
  color: var(--verify-copy);
}

/* state accents: mark colour + a soft ring around the card */
.verify-card[data-state="success"] .verify-mark { background: rgba(40, 168, 0, 0.12); color: var(--success); }
.verify-card[data-state="success"] { border-color: rgba(40, 168, 0, 0.35); }
.verify-card[data-state="error"] .verify-mark { background: rgba(248, 7, 24, 0.1); color: var(--danger); }
.verify-card[data-state="error"] { border-color: rgba(248, 7, 24, 0.3); }

/* pending: gentle pulse on the mark, skipped when the user asks for less motion */
.verify-card[data-state="pending"] .verify-mark { animation: verify-pulse 1.6s ease-in-out infinite; }
@keyframes verify-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(171, 131, 85, 0.25); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(171, 131, 85, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .verify-card[data-state="pending"] .verify-mark { animation: none; }
  .verify-mark { transition: none; }
}

@media (max-width: 480px) {
  .verify-card { padding: 28px 20px 22px; border-radius: var(--radius-md); }
  .verify-actions .btn { width: 100%; }
}

/* ───────────────────────── password reset route ─────────────────────────────
   /reset-password. Same exclusive-route treatment as /verify-email: same
   layout rhythm, its own state colours, and the same 42px tap targets so the
   form is usable on a phone from an email link. */
.reset-view {
  min-height: 100vh;
  width: 100vw;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(171, 131, 85, 0.12), transparent 60%),
    var(--bg);
}

.reset-card {
  --reset-copy: #6f5d49;
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 38px 30px;
  text-align: center;
  color: var(--reset-copy);
}

.reset-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(171, 131, 85, 0.12);
  color: #8a6a3d;
  transition: background 0.2s ease, color 0.2s ease;
}
.reset-mark svg { width: 30px; height: 30px; }

.reset-title { margin: 0 0 8px; font-size: 24px; line-height: 1.25; color: var(--text); }
.reset-lead { margin: 0 0 20px; font-size: 15px; }
.reset-detail { margin: 12px 0 0; font-size: 13px; }
.reset-detail:empty { display: none; }

.reset-form { text-align: left; display: grid; gap: 8px; margin-top: 4px; max-width: 420px; margin-left: auto; margin-right: auto; }
.reset-form[hidden] { display: none; }
.reset-form .label { margin-top: 8px; }
.reset-form .controls { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.reset-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.reset-actions[hidden] { display: none; }
.reset-foot { margin: 22px 0 0; font-size: 12px; color: var(--reset-copy); }

.reset-card[data-state="success"] .reset-mark { background: rgba(40, 168, 0, 0.12); color: var(--success); }
.reset-card[data-state="success"] { border-color: rgba(40, 168, 0, 0.35); }
.reset-card[data-state="error"] .reset-mark { background: rgba(248, 7, 24, 0.1); color: var(--danger); }
.reset-card[data-state="error"] { border-color: rgba(248, 7, 24, 0.3); }
.reset-card[data-state="pending"] .reset-mark { background: rgba(171, 131, 85, 0.18); color: #8a6a3d; }

@media (prefers-reduced-motion: reduce) {
  .reset-mark { transition: none; }
}

/* ───────────────────────── password policy checklist ─────────────────────────
   Shared by the reset card and the change-password modal. The tick is a
   pseudo-element rather than a character so it can sit inline with the label
   without changing the line height. */
.pw-rules {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--reset-copy, #6f5d49);
}
.pw-rules li { display: flex; align-items: center; gap: 8px; }
.pw-tick {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  border: 1.5px solid #c9b79c;
  background: transparent;
  position: relative;
}
.pw-rules li.is-met { color: var(--success); }
.pw-rules li.is-met .pw-tick { border-color: var(--success); background: rgba(40, 168, 0, 0.1); }
.pw-rules li.is-met .pw-tick::after {
  content: "";
  position: absolute;
  inset: 0;
  background: no-repeat center / 10px 8px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8'%3E%3Cpath d='M1 4.2 3.6 6.8 9 1.4' fill='none' stroke='%2328a800' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.pw-hint { display: block; min-height: 16px; font-size: 12px; color: #8a7660; }
.pw-hint.is-ok { color: var(--success); }
.pw-hint.is-bad { color: var(--danger); }

/* The reset card and the modal share the min tap target the rest of the app
   uses on touch screens. */
.reset-actions .btn,
.reset-form .btn,
#forgotSubmitBtn,
#changeSubmitBtn { min-height: 42px; }

@media (max-width: 480px) {
  .reset-card { padding: 28px 20px 22px; border-radius: var(--radius-md); }
  .reset-actions .btn { width: 100%; }
  .reset-form .controls { flex-direction: column-reverse; }
  .reset-form .controls .btn { width: 100%; }
}
