/* ==========================================================================
   Tulsi OS3 — Zero-Waste Monochrome
   ========================================================================== */

/* --- Custom Properties --- */
:root {
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --border: #e5e7eb;
  --border-subtle: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --hover: #f9fafb;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 3px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  padding: 0 16px 24px;
}

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Typography --- */
h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 8px;
}

h2 {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 6px;
}

h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}

p { margin: 4px 0; }
small { color: var(--muted); }
em { font-style: italic; color: var(--muted); }
strong { font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* --- Navigation --- */
.nav-container {
  height: 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin: 0 -16px;
  padding: 0 16px;
  display: flex;
  align-items: center;
}

.nav-brand {
  display: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  margin-left: auto;
}

.nav-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.nav-menu {
  list-style: none;
  display: flex;
  align-items: center;
  height: 100%;
  width: 100%;
}

.nav-item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-link:hover { background: var(--hover); text-decoration: none; }

.dropdown-toggle { cursor: pointer; padding-right: 22px; }

.dropdown-toggle::after {
  content: '+';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--faint);
  font-weight: 600;
}

.dropdown-toggle.active::after { content: '-'; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dropdown-menu.show { display: block; }

.dropdown-menu a {
  display: block;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
}

.dropdown-menu a:last-child { border-bottom: none; }
.dropdown-menu a:hover { background: var(--hover); text-decoration: none; }

.nav-right { margin-left: auto; }

.nav-logout {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 12px;
  height: 100%;
  font-family: inherit;
}

.nav-logout:hover { color: var(--text); background: var(--hover); }

/* --- Tables --- */
.table-wrap {
  width: 100%;
}

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

thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 7px 10px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

tbody tr:hover { background: var(--hover); }

tfoot td {
  padding: 7px 10px;
  font-weight: 600;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
}

/* --- Buttons --- */
button, .btn, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

button:hover, .btn:hover, input[type="submit"]:hover { background: var(--hover); }

button[type="submit"], .btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

button[type="submit"]:hover, .btn-primary:hover {
  background: #374151;
  border-color: #374151;
}

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

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

button:disabled, button[disabled] { opacity: 0.4; cursor: not-allowed; }

/* --- Forms --- */
label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  display: block;
  margin-bottom: 2px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
select,
textarea {
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
  width: 100%;
  max-width: 360px;
}

textarea { height: auto; padding: 6px 8px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
}

input[type="checkbox"] { cursor: pointer; display: inline; width: auto; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.form-row > div { flex: 1; min-width: 0; }
.form-row > div input,
.form-row > div select,
.form-row > div textarea { max-width: none; }

.form-group { margin-bottom: 12px; }

.form-hint { font-size: 12px; color: var(--muted); margin-top: 2px; display: block; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.form-actions a { font-size: 13px; color: var(--muted); }
.form-actions a:hover { color: var(--text); }

/* Field width modifiers */
.input-xs { max-width: 80px; }
.input-sm { max-width: 160px; }
.input-md { max-width: 240px; }
.input-lg { max-width: 360px; }
.input-full { max-width: none; }

/* --- Messages / Alerts --- */
.messages { margin: 8px 0; }

.message {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid var(--border);
  margin-bottom: 4px;
  background: var(--bg-subtle);
}

.message-error { border-left-color: var(--danger); color: var(--danger); }
.message-warning { border-left-color: #d97706; color: #d97706; }
.message-success { border-left-color: var(--success); color: var(--success); }
.message-info { border-left-color: var(--muted); color: var(--muted); }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid;
  border-radius: var(--radius);
  line-height: 1.5;
}

.badge-green { color: var(--success); border-color: var(--success); }
.badge-red { color: var(--danger); border-color: var(--danger); }
.badge-gray { color: var(--muted); border-color: var(--border); }
.badge-blue { color: #2563eb; border-color: #2563eb; }

/* --- Status Indicators --- */
.status-active { color: var(--success); font-weight: 600; }
.status-stopped { color: var(--danger); font-weight: 600; }
.status-created { color: var(--success); }
.status-updated { color: #2563eb; }
.status-deleted { color: var(--danger); }

/* --- Lists --- */
ul, ol { padding-left: 16px; }

.list-plain {
  list-style: none;
  padding: 0;
}

.list-plain li {
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.list-plain li:last-child { border-bottom: none; }

/* --- Details/Summary --- */
details { margin-top: 2px; }

details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

details summary:hover { color: var(--text); }

details ul { margin: 4px 0; padding-left: 16px; font-size: 13px; }
details li { padding: 1px 0; }

/* --- Breadcrumb --- */
.breadcrumb { font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

/* --- Pagination --- */
.pagination {
  margin: 10px 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination a {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 500;
}

.pagination a:hover { background: var(--hover); text-decoration: none; }
.pagination .current { color: var(--muted); }

/* --- Section box --- */
.section-box {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 8px 0;
}

/* --- Scan interface --- */
.scan-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 8px 0;
}

.scan-box hr { margin: 12px 0; }

.scan-box select { max-width: none; }

.scan-status-bar {
  display: none;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid var(--border);
  background: var(--bg-subtle);
  margin-bottom: 10px;
}

.scan-status-bar.is-success { border-left-color: var(--success); color: var(--success); }
.scan-status-bar.is-warning { border-left-color: #d97706; color: #d97706; }
.scan-status-bar.is-error { border-left-color: var(--danger); color: var(--danger); }
.scan-status-bar.is-info { border-left-color: var(--muted); color: var(--muted); }

.scan-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.scan-row select { flex: 1; }
.scan-row button { flex-shrink: 0; }

/* --- Camera / QR --- */
#camera-container {
  margin: 10px 0;
  max-width: 400px;
}

#camera-container .camera-inner {
  background: #000;
  padding: 8px;
  border-radius: var(--radius);
}

#camera-container .camera-inner video {
  width: 100%;
  display: block;
  border-radius: var(--radius);
}

#camera-container .camera-inner p {
  color: #fff;
  margin-top: 6px;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 768px) {
  #camera-container.camera-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    max-width: none;
    background: #000;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  #camera-container.camera-fullscreen .camera-inner {
    position: absolute;
    inset: 0;
    padding: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  #camera-container.camera-fullscreen .camera-inner p {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    z-index: 1;
  }
  #camera-container.camera-fullscreen #qr-video,
  #camera-container.camera-fullscreen .camera-inner video {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    border-radius: 0;
  }
  #camera-container.camera-fullscreen #qr-reader {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  #camera-container.camera-fullscreen #qr-reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
  #camera-container.camera-fullscreen .camera-done-btn {
    display: block !important;
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
  }
  #camera-container.camera-fullscreen .camera-scan-feedback {
    position: fixed;
    top: 22%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    padding: 8px 16px;
    background: rgba(22, 163, 74, 0.95);
    color: #fff;
    font-size: 48px;
    font-weight: 600;
    border-radius: var(--radius);
    text-align: center;
    pointer-events: none;
  }
}

/* --- Dashboard --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.kpi-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
}

.kpi-card .value {
  font-size: 24px;
  font-weight: 600;
  display: block;
  color: var(--text);
}

.kpi-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.panel h2 {
  margin: 0 0 8px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.panel table {
  font-size: 13px;
  width: 100%;
  table-layout: fixed;
  display: table;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  height: 100px;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.bar-chart .bar { flex: 1; background: var(--text); min-height: 0; }
.bar-chart .bar.empty { background: var(--border-subtle); min-height: 2px; }

.bar-labels {
  display: flex;
  gap: 3px;
  font-size: 10px;
  color: var(--faint);
}

.bar-labels span {
  flex: 1;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.capacity-bar {
  height: 12px;
  background: var(--border-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
}

.capacity-bar .fill {
  height: 100%;
  background: var(--text);
  border-radius: var(--radius);
}

details.panel > summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  list-style: none;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  cursor: pointer;
}

details.panel > summary::before {
  content: '+';
  font-size: 11px;
}

details.panel[open] > summary::before { content: '-'; }

.see-more-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  display: block;
  margin-top: 4px;
}

.see-more-btn:hover { color: var(--text); }

@media (max-width: 700px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  .bar-labels span:nth-child(even) { visibility: hidden; }
  .panel { overflow-x: auto; }
  .panel table { table-layout: auto; }
}

/* --- Confirm page --- */
.confirm-table { width: 100%; margin: 8px 0; }
.confirm-table thead th { text-align: left; }
.confirm-table td { vertical-align: middle; }

.harvest-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 10px 0;
}

.harvest-box .form-group { margin-bottom: 14px; }

.harvest-box .quantity-input {
  font-size: 24px;
  font-weight: 600;
  height: 48px;
  max-width: 200px;
  padding: 0 12px;
}

.harvest-box textarea {
  max-width: 100%;
}

.harvest-box .form-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.warning-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d97706;
  border-radius: var(--radius);
  cursor: pointer;
  max-width: 400px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  color: #d97706;
  min-height: 40px;
}

.warning-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Active mesh card --- */
.active-mesh-card {
  padding: 8px 10px;
  border: 1px solid var(--success);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

/* --- Quick add form --- */
.quick-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-width: 400px;
}

.quick-form .form-group { margin-bottom: 12px; }

.quick-form label { margin-bottom: 2px; }

.quick-form input,
.quick-form select {
  width: 100%;
  max-width: none;
}

/* --- Login page --- */
.login-page {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.login-box h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
}

.login-box input[type="text"],
.login-box input[type="password"] {
  width: 100%;
  max-width: none;
  margin-bottom: 12px;
}

.login-box button[type="submit"] {
  width: 100%;
  height: 36px;
  justify-content: center;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
}

/* --- Crop allocation cards --- */
.crop-card {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.crop-card .crop-available { color: var(--success); font-weight: 600; }

.crop-card input[type="number"] { width: 60px; }

/* --- Growing mesh detail actions --- */
.gm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.gm-actions form { margin: 0; }

/* --- Movement steps --- */
.step { margin: 8px 0; }
.step-hidden { display: none; }

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }

.validation-message {
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  margin: 8px 0;
}

.scan-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.scan-list li {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  gap: 10px;
  font-size: 13px;
  background: var(--bg);
}

.scan-list-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.scan-list-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-list-label strong {
  color: var(--text);
  margin-right: 4px;
}

.scan-list li button {
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  padding: 4px 6px;
  border-radius: var(--radius);
}

.scan-list li button:hover { color: var(--danger); background: var(--hover); }

/* --- DataTables overrides --- */
.dataTables_wrapper {
  font-size: 13px !important;
  font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

.dataTables_wrapper .dataTables_filter input {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  display: inline-block;
  width: auto;
  max-width: none;
}

.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--text);
}

.dataTables_wrapper .dataTables_length select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  display: inline-block;
  width: auto;
  max-width: none;
}

.dataTables_wrapper .dataTables_info {
  font-size: 13px;
  color: var(--muted);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 4px 10px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  font-size: 13px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--hover) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--text) !important;
  color: var(--bg) !important;
  border-color: var(--text) !important;
}

table.dataTable thead th {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--faint) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  background: var(--bg-subtle) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 7px 10px !important;
}

table.dataTable tbody td {
  padding: 7px 10px !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

table.dataTable tbody tr:hover { background: var(--hover) !important; }
table.dataTable { border-collapse: collapse !important; }

/* --- Spinner (only animation) --- */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* --- Mobile Bottom Tab Bar (hidden on desktop) --- */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 1000;
  align-items: stretch;
  justify-content: space-around;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 2px;
  padding: 6px 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.tabbar-item:hover,
.tabbar-item:active {
  text-decoration: none;
  color: var(--text);
}

.tabbar-icon {
  width: 22px;
  height: 22px;
}

.tabbar-item-primary {
  position: relative;
  gap: 4px;
  padding-top: 0;
  padding-bottom: 6px;
  margin-top: -20px;
}

.tabbar-item-primary .tabbar-icon {
  width: 26px;
  height: 26px;
  color: var(--bg);
  stroke: var(--bg);
  background: var(--text);
  border-radius: 50%;
  padding: 8px;
  box-sizing: content-box;
  border: 3px solid var(--bg);
}

.tabbar-item-primary span {
  color: var(--text);
  font-weight: 600;
  font-size: 10px;
}

/* --- Mobile "More" Menu (hidden by default) --- */
.mobile-more-menu {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 60px;
  background: var(--bg);
  z-index: 999;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-more-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}

.mobile-more-header button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}

.mobile-more-section {
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px 0;
}

.mobile-more-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px 4px;
}

.mobile-more-section a {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
}

.mobile-more-section a:active {
  background: var(--hover);
}

.mobile-more-logout {
  margin-top: auto;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.mobile-more-logout button {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
}

/* ==========================================================================
   Mobile Responsive — 600px breakpoint
   ========================================================================== */
@media (max-width: 600px) {

  /* --- Base --- */
  body { padding: 0 10px; }

  /* --- Typography — slightly larger for readability on small screens --- */
  html { font-size: 14px; }

  h1 { font-size: 16px; margin: 10px 0 6px; }

  /* --- Hide desktop top navbar, show bottom tabbar --- */
  .nav-container { display: none; }
  body { padding-bottom: 68px; }
  .mobile-tabbar { display: flex; }
  .mobile-more-menu.show { display: flex; }

  /* --- Tables — scrollable wrapper approach --- */
  .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 500px;
  }

  thead th, tbody td, tfoot td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  /* DataTables on mobile — the wrapper div already scrolls */
  .dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dataTables_wrapper table.dataTable {
    min-width: 500px;
  }

  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length {
    margin-bottom: 8px;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
    height: 36px;
    font-size: 14px;
  }

  .dataTables_wrapper .dataTables_length select {
    height: 36px;
    font-size: 14px;
  }

  .dataTables_wrapper .dataTables_paginate {
    margin-top: 8px;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 8px 12px !important;
    font-size: 14px !important;
    min-height: 36px !important;
  }

  /* --- Buttons — larger touch targets --- */
  button, .btn, input[type="submit"] {
    padding: 8px 14px;
    font-size: 14px;
    min-height: 40px;
  }

  /* --- Forms — full width, larger targets --- */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    width: 100%;
    max-width: none;
    height: 36px;
    font-size: 14px;
    padding: 0 10px;
  }

  textarea { height: auto; padding: 8px 10px; }

  select { max-width: none !important; }

  .form-row { flex-direction: column; gap: 10px; }
  .form-row > div { flex: none; }

  .form-group { margin-bottom: 14px; }

  label { font-size: 13px; margin-bottom: 4px; }

  .form-hint { font-size: 13px; }

  .form-actions { margin-top: 20px; }

  .input-xs, .input-sm, .input-md, .input-lg { max-width: none; }

  /* --- Breadcrumbs — wrap on small screens --- */
  .breadcrumb {
    font-size: 12px;
    word-break: break-word;
    line-height: 1.6;
  }

  /* --- Scan interface --- */
  .scan-box { padding: 12px; }

  .scan-row { flex-direction: column; }
  .scan-row select { width: 100%; }
  .scan-row button { width: 100%; justify-content: center; }

  #camera-container { max-width: 100%; }

  .scan-list { max-width: 100%; }

  /* --- Quick form — full width on mobile --- */
  .quick-form { max-width: 100%; }

  /* --- Harvest box --- */
  .harvest-box .quantity-input {
    max-width: none;
    font-size: 28px;
    height: 56px;
    text-align: center;
  }

  .harvest-box textarea { max-width: none; }

  .warning-label { max-width: 100%; }

  /* --- Crop cards --- */
  .crop-card input[type="number"] { width: 100%; max-width: none; }

  /* --- Login box --- */
  .login-box {
    max-width: 100%;
    padding: 20px 16px;
    border: none;
    border-radius: 0;
  }

  .login-box button[type="submit"] { height: 44px; font-size: 14px; }
  .login-box input[type="text"],
  .login-box input[type="password"] { height: 40px; margin-bottom: 14px; }

  /* --- Scan lists --- */
  .scan-list li {
    font-size: 13px;
    padding: 10px;
    min-height: 44px;
  }

  .scan-list li button { padding: 6px 8px; font-size: 16px; }

  .scan-status-bar { font-size: 14px; padding: 10px 12px; }

  /* --- Pagination --- */
  .pagination { flex-wrap: wrap; }
  .pagination a { padding: 8px 12px; font-size: 14px; }

  /* --- Messages --- */
  .message { font-size: 14px; padding: 8px 10px; }

  /* --- KPI grid --- */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card .value { font-size: 20px; }
  .kpi-card .label { font-size: 10px; }

  /* --- Confirm table wrapper handled by .table-wrap --- */

  /* --- Section box --- */
  .section-box { padding: 10px; }

  /* --- Details on mobile --- */
  details summary { font-size: 14px; }
}

/* ==========================================================================
   Room Visualization
   ========================================================================== */

/* --- Screen 1: Room overview --- */
.rv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

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

.rv-room-name {
  font-size: 15px;
  font-weight: 600;
}

.rv-room-select {
  height: 28px;
  padding: 0 6px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  width: auto;
  max-width: none;
  display: inline-block;
  color: var(--text);
}

.rv-legend {
  display: flex;
  gap: 16px;
  padding: 6px 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.rv-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rv-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.rv-dot-growing { background: #0d9488; }
.rv-dot-ready { background: #d97706; }
.rv-dot-empty { background: #d1d5db; }

.rv-columns {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  padding-bottom: 24px;
}

.rv-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rv-column-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
  text-align: center;
}

.rv-divider {
  width: 1px;
  background: var(--border);
  margin: 0 10px;
}

.rv-unit-card {
  display: block;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}

.rv-unit-card:hover {
  background: var(--hover);
  text-decoration: none;
}

.rv-unit-selected {
  border-color: #0d9488;
  background: #f0fdfa;
}

.rv-unit-name {
  font-size: 13px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.rv-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* --- Screen 2: Unit detail --- */
.uv-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.uv-back {
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  line-height: 1;
}

.uv-back:hover { color: var(--muted); text-decoration: none; }

.uv-topbar-text {
  display: flex;
  flex-direction: column;
}

.uv-title {
  font-size: 15px;
  font-weight: 600;
}

.uv-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.uv-levels {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.uv-level-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.uv-level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-subtle);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.uv-occupancy {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.uv-areas-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

.uv-area-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  min-height: 52px;
  text-align: center;
  border-right: 1px solid var(--border-subtle);
}

.uv-area-cell:last-child { border-right: none; }

a.uv-area-cell { text-decoration: none; color: inherit; }
a.uv-area-cell:hover { opacity: 0.8; }

.uv-area-growing {
  background: #f0fdfa;
  border-color: #0d9488;
}

.uv-area-growing + .uv-area-growing { border-left: 1px solid #0d9488; }

.uv-area-ready {
  background: #fffbeb;
  border-color: #d97706;
}

.uv-area-ready + .uv-area-ready { border-left: 1px solid #d97706; }

.uv-area-dash {
  color: var(--faint);
  font-size: 16px;
}

.uv-area-crop {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.uv-area-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 600px) {
  .rv-columns { gap: 0; }
  .rv-divider { margin: 0 6px; }
  .rv-unit-card { padding: 8px; }
  .uv-area-cell { padding: 8px 2px; min-height: 46px; }
  .uv-area-crop { font-size: 11px; }
}
