/* ============================================================
 * Shipmunk Design System — Standalone CSS
 * ============================================================
 *
 * Drop this file into any project (PHP, Node, Python, Go, static HTML)
 * to get the Shipmunk dark UI instantly.
 *
 * External dependencies (load from CDN in your HTML <head>):
 *   <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
 *   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
 *   <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap" rel="stylesheet">
 *
 * Then load this file AFTER Bulma:
 *   <link rel="stylesheet" href="/assets/css/shipmunk.css">
 * ============================================================ */

/* ----------------------------------------------------------
 * 1. Design Tokens (CSS Custom Properties)
 * ---------------------------------------------------------- */

:root {
  /* Backgrounds */
  --color-bg: #0f0f0f;
  --color-bg-secondary: #1a1a1a;
  --color-bg-tertiary: #2d2d2d;

  /* Text */
  --color-text: #a0a0a0;
  --color-text-secondary: #808080;
  --color-text-muted: #666666;
  --color-strong: #ffffff;

  /* Borders */
  --color-border: #333333;
  --color-border-light: #2a2a2a;

  /* Accent */
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: rgba(79, 70, 229, 0.15);
  --brand-coral: #ef4444;

  /* Status */
  --color-success: #10b981;
  --color-success-light: rgba(16, 185, 129, 0.15);
  --color-error: #ef4444;
  --color-error-light: rgba(239, 68, 68, 0.15);
  --color-warning: #fb923c;
  --color-warning-light: rgba(251, 146, 60, 0.15);
  --color-info: #3b82f6;
  --color-info-light: rgba(59, 130, 246, 0.15);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Typography */
  --font-sans: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Monaco', 'Courier New', monospace;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.875rem;
  --font-size-lg: 1rem;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 48px;
}


/* ----------------------------------------------------------
 * 2. Base Reset & Body
 * ---------------------------------------------------------- */

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
}

* { font-family: var(--font-sans); }

::selection { background: rgba(79, 70, 229, 0.55); color: #ffffff; }
::-moz-selection { background: rgba(79, 70, 229, 0.55); color: #ffffff; }

code, pre, pre code { background-color: transparent; color: var(--color-strong); }
pre { padding: 0; }


/* ----------------------------------------------------------
 * 3. Layout Shell (Sidebar + Main)
 * ---------------------------------------------------------- */

#app {
  display: flex;
  min-height: 100vh;
  flex-direction: row;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  z-index: 101;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 1.5rem;
  margin-bottom: 2rem;
  margin: 0 auto;
}

.sidebar-brand img {
  margin-bottom: 10px;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-strong);
  text-decoration: none;
}

.sidebar-brand a span { color: var(--brand-coral); }

.sidebar-product {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 0 1.75rem;
  padding: 0 1.5rem;
}

.sidebar-product::before,
.sidebar-product::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--color-border));
}

.sidebar-product::after {
  background: linear-gradient(to left, transparent, var(--color-border));
}

.sidebar-product-name {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.45em;
  margin-right: -0.45em;
  text-transform: uppercase;
  color: var(--color-strong);
  text-decoration: none;
}

.sidebar-product-name i {
  font-size: 0.8rem;
  letter-spacing: 0;
  color: var(--brand-coral);
}

.sidebar-product-name:hover,
.sidebar-product-name:focus,
.sidebar-product-name:active,
.sidebar-product-name:visited {
  color: var(--color-strong);
  text-decoration: none;
}

.sidebar-product-name:hover i,
.sidebar-product-name:focus i,
.sidebar-product-name:active i {
  color: var(--brand-coral);
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text);
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.sidebar-nav a i {
  width: 1.25rem;
  text-align: center;
  font-size: 1rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--color-primary);
  background-color: var(--color-bg-tertiary);
}

.sidebar-nav a:hover i,
.sidebar-nav a.active i {
  color: var(--color-primary);
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.5rem 0;
  border-top: 1px solid var(--color-border);
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.sidebar-user .name {
  color: var(--color-strong);
  font-weight: 600;
}

.app-container {
  display: flex;
  flex: 1;
  width: 100%;
  margin-left: var(--sidebar-width);
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  background-color: var(--color-bg);
  width: 100%;
  min-height: 100vh;
}

/* Mobile */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-strong);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 1rem;
}

@media screen and (max-width: 768px) {
  #app { flex-direction: column; }
  .sidebar { left: -260px !important; transition: left 0.3s ease; }
  .sidebar.open { left: 0 !important; }
  .mobile-nav-toggle { display: block; }
  .app-container { margin-left: 0; }
  .main-content { padding: 1rem; }
}


/* ----------------------------------------------------------
 * 4. Buttons
 * ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-tertiary);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn:hover {
  background-color: #383838;
  color: var(--color-strong);
}

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

.btn-primary {
  background-color: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  color: white;
}

.btn-secondary {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: #383838;
}

.btn-success {
  background-color: var(--color-success);
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-tertiary);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}


/* ----------------------------------------------------------
 * 5. Form Elements
 * ---------------------------------------------------------- */

/* Every text-like control, not an explicit type list: a control written
   `<input readonly>` has no `type` attribute at all, so `input[type="text"]`
   never matched it and it fell back to the UA's white box on the dark form.
   :where() keeps the selector at element specificity so the readonly and
   focus rules below still win. */
input:where(
  :not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="range"]):not([type="file"]):not([type="color"])
),
select,
textarea {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  background-color: var(--color-bg-tertiary);
  color: var(--color-strong);
}

input[type="file"] {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-tertiary);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

/* The UA paints the "Choose file" button itself, so it needs the
   ::file-selector-button hook - the rule above cannot reach it. */
input[type="file"]::file-selector-button {
  margin-right: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-secondary);
  color: var(--color-strong);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="file"]:hover::file-selector-button {
  background-color: #383838;
  border-color: var(--color-primary);
}

input[type="file"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

input[type="file"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* A locked value (e.g. the fixed SGD currency) reads as surface, not as
   something an operator can type into. */
input[readonly],
textarea[readonly] {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-border-light);
  color: var(--color-text);
  cursor: default;
}

input[readonly]:focus,
textarea[readonly]:focus {
  border-color: var(--color-border-light);
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}

.form-group label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

.required { color: var(--color-error); }

.form-error {
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-sm);
  background: var(--color-error-light);
  color: var(--color-strong);
}


/* ----------------------------------------------------------
 * 6. Filter Bar
 * ---------------------------------------------------------- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  flex-wrap: wrap;
}

.filter-search-input {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  min-width: 200px;
  color: var(--color-strong);
  background-color: var(--color-bg-tertiary);
}

.filter-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.filter-view-select {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  color: var(--color-strong);
  background-color: var(--color-bg-tertiary);
}


/* ----------------------------------------------------------
 * 7. Toolbar
 * ---------------------------------------------------------- */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  gap: var(--space-md);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}


/* ----------------------------------------------------------
 * 8. Pager
 * ---------------------------------------------------------- */

.pager {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
}

.pager-info {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.pager-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.pager-btn {
  padding: var(--space-xs) var(--space-sm);
  min-width: 2rem;
}

.pager-page {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.pager-select {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  color: var(--color-strong);
  background-color: var(--color-bg-tertiary);
}


/* ----------------------------------------------------------
 * 9. Modal Dialog (native <dialog>)
 * ---------------------------------------------------------- */

dialog.modal {
  display: none;
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-height: 90vh;
  overflow: auto;
  z-index: 1000;
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}

dialog.modal[open] { display: block; }

dialog.modal::backdrop {
  background: rgba(0,0,0,0.6);
}

dialog.modal .modal-content {
  padding: var(--space-xl);
  margin: 0;
  width: auto;
  max-height: none;
  overflow: visible;
  position: static;
}

dialog.modal .modal-close {
  position: static;
  width: auto;
  height: auto;
  max-height: none;
  max-width: none;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text);
  border: none;
  cursor: pointer;
}

dialog.modal .modal-close:hover {
  background: none;
  color: var(--color-strong);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-header h2 {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--color-strong);
}

.modal-body {
  margin-bottom: var(--space-xl);
  color: var(--color-text);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}


/* ----------------------------------------------------------
 * 10. Toast Notifications
 * ---------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  min-width: 200px;
  box-shadow: var(--shadow-md);
}

.toast-success {
  background-color: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.toast-error {
  background-color: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.toast-info {
  background-color: var(--color-info-light);
  color: var(--color-info);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.toast-warning {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid rgba(251, 146, 60, 0.3);
}

.toast-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
  font-size: 1rem;
  opacity: 0.7;
  color: inherit;
}

.toast-dismiss:hover { opacity: 1; }


/* ----------------------------------------------------------
 * 11. Drawer (slide-in panel)
 * ---------------------------------------------------------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 90vw;
  height: 100vh;
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.drawer-header h3 {
  margin: 0;
  color: var(--color-strong);
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}


/* ----------------------------------------------------------
 * 12. Save Bar (unsaved changes indicator)
 * ---------------------------------------------------------- */

.save-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  justify-content: center;
  min-width: 0;
  margin: 0 var(--space-md);
  padding: 0 var(--space-xs) 0 var(--space-md);
  height: 29px;
  box-sizing: border-box;
  background-color: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-strong);
}

.save-bar[hidden] { display: none; }

.save-bar.has-errors {
  background-color: var(--color-error-light);
  border-color: var(--color-error);
}

.save-bar-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background-color: var(--color-warning);
}

.save-bar.has-errors .save-bar-dot {
  background-color: var(--color-error);
}

.save-bar-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.save-bar-actions {
  display: flex;
  flex: none;
  gap: var(--space-xs);
  margin-left: auto;
}


/* ----------------------------------------------------------
 * 13. Dropdown Menu
 * ---------------------------------------------------------- */

.dropdown-menu {
  display: block;
  position: absolute;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  min-width: 160px;
  padding: var(--space-xs) 0;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-xs) var(--space-md);
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-family: var(--font-sans);
}

.dropdown-item:hover {
  background: var(--color-bg-tertiary);
}

.dropdown-danger { color: var(--color-error); }


/* ----------------------------------------------------------
 * 14. Flash Messages
 * ---------------------------------------------------------- */

.flash-success {
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.flash-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}


/* ----------------------------------------------------------
 * 15. Warning Box
 * ---------------------------------------------------------- */

.warning-box {
  margin: var(--space-sm) 0;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-sm);
  background: var(--color-warning-light);
  color: var(--color-strong);
}

.warning-box p { margin: 0 0 var(--space-xs); }


/* ----------------------------------------------------------
 * 16. Data Table
 * ---------------------------------------------------------- */

.item-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-md);
}

.item-table th {
  text-align: left;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.item-table td {
  padding: var(--space-xs) var(--space-sm);
  vertical-align: top;
  border-top: 1px solid var(--color-border);
}

.item-table td input {
  width: 100%;
  min-width: 70px;
}


/* ----------------------------------------------------------
 * 17. Summary / Key-Value Pairs
 * ---------------------------------------------------------- */

.row-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.summary-field {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--font-size-sm);
}

.summary-label {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.summary-value {
  color: var(--color-strong);
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ----------------------------------------------------------
 * 18. Status Badges
 * ---------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-error   { background: var(--color-error-light);   color: var(--color-error); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-info    { background: var(--color-info-light);    color: var(--color-info); }


/* ----------------------------------------------------------
 * 19. History / Audit Log
 * ---------------------------------------------------------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.history-entry {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.history-entry:last-child { border-bottom: none; }

.history-header {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-xs);
}

.history-time {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

.history-user {
  color: var(--color-strong);
  font-weight: 500;
}

.history-fields {
  padding-left: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-field {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.history-field .field-label {
  font-weight: 500;
  color: var(--color-strong);
}

.history-field .old-value { color: var(--color-error); }
.history-field .new-value { color: var(--color-success); }


/* ----------------------------------------------------------
 * 20. Handsontable Overrides (dark theme)
 * ---------------------------------------------------------- */

.ht-theme-main-dark {
  --ht-background-color: var(--color-bg);
  --ht-background-secondary-color: var(--color-bg-secondary);
  --ht-border-color: var(--color-border);
  --ht-foreground-color: var(--color-text);
}

.htCore td {
  background-color: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

.htCore th {
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
  border-color: var(--color-border);
}

div.handsontable td.cell-dirty {
  background-color: var(--color-warning-light) !important;
  box-shadow: inset 3px 0 0 var(--color-warning);
}

div.handsontable td.cell-invalid {
  background-color: var(--color-error-light) !important;
  box-shadow: inset 3px 0 0 var(--color-error);
  outline: none;
}

div.handsontable td.cell-default {
  color: var(--color-text-muted);
  font-style: italic;
}

div.handsontable td.status-ok {
  color: var(--color-success) !important;
}

div.handsontable td.status-bad {
  color: var(--color-error) !important;
}

td.cell-readonly { color: var(--color-text-muted); }

th .sort-indicator {
  font-size: 0.75rem;
  margin-left: 4px;
}

/* Suppress focus outlines on grid mount elements */
[data-test="main"]:focus,
[data-test="main"]:focus-visible,
[data-test="crud-grid-root"]:focus,
[data-test="crud-grid-root"]:focus-visible,
[data-view]:focus-visible {
  outline: none;
}


/* ----------------------------------------------------------
 * 21. Mobile: stop iOS focus zoom
 * ---------------------------------------------------------- */

/* Mobile Safari force-zooms the page when a focused text control computes
   under 16px, and leaves the layout zoomed afterwards. The floor is the fix:
   `maximum-scale=1` in the viewport meta is ignored by iOS 10+ for this and
   only costs Android users pinch-zoom. `pointer: coarse` catches tablets
   wider than the 768px breakpoint, which is the branch a desktop browser can
   exercise. The class selectors matter: apps that style `.form-input` etc.
   out-specify a bare element list. */

@media (pointer: coarse), screen and (max-width: 768px) {
  input:not([type='checkbox']):not([type='radio']):not([type='submit']):not([type='button']):not([type='reset']):not([type='range']):not([type='file']):not([type='color']),
  select,
  textarea,
  .input,
  .textarea,
  .select select,
  .form-input,
  .form-textarea,
  .form-select {
    font-size: 16px !important;
  }
}
