:root {
  --bg: #e8e8e8;
  --panel: #ffffff;
  --panel-2: #f3f3f3;
  --text: #000000;
  --muted: #555555;
  --accent: #ed4214;
  --accent-soft: #ff6a3d;
  --accent-2: #15803d;
  --border: #cfcfcf;
  --danger: #dc2626;
  --accent-rgb: 237, 66, 20;
}

* { box-sizing: border-box; }
img, video, svg { max-width: 100%; height: auto; }
html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #f5f5f5, #e8e8e8 45%, #dcdcdc);
  color: var(--text);
  min-height: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
body.no-scroll { overflow: hidden; touch-action: none; }

.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; min-width: 0; }

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-close { display: none; }

.sidebar {
  background: #efefef;
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.brand { display: flex; gap: 14px; align-items: center; position: relative; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #ff6a3d);
  font-weight: 700;
  color: #fff;
  box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.25);
}
.brand h1 { margin: 0; font-size: 1.1rem; color: var(--text); }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

nav { display: flex; flex-direction: column; gap: 8px; }
.nav-link {
  display: block;
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  padding: 12px 14px;
  border-radius: 12px;
}
.nav-link.active, .nav-link:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.35);
}
.nav-link.active {
  color: var(--accent);
  font-weight: 600;
}

.db-status {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.85rem;
}
.db-status.ok { color: var(--accent-2); }
.db-status.error { color: var(--danger); }

.content {
  padding: 28px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-header { margin-bottom: 24px; }
.page-header h2 { margin: 0 0 6px; font-size: 1.8rem; }
.page-header p { margin: 0; color: var(--muted); }
.page-header.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
}

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid var(--danger);
  color: #991b1b;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.stat-card span { color: var(--muted); font-size: 0.85rem; }
.stat-card strong { display: block; margin-top: 8px; font-size: 1.6rem; }

.welcome-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 28px 30px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.12), transparent 42%),
    linear-gradient(135deg, #fafafa, #eeeeee);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.06);
}
.welcome-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.welcome-banner h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  font-weight: 700;
}
.welcome-sub {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 42ch;
}
.welcome-meta {
  text-align: right;
  min-width: 140px;
}
.welcome-date {
  color: var(--muted);
  font-size: 0.9rem;
}
.welcome-day {
  margin-top: 4px;
  font-size: 1.15rem;
  font-weight: 600;
}
.stat-card.accent-card {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.08), #ffffff);
}
.stat-card.highlight-card {
  border-color: rgba(21, 128, 61, 0.3);
  background: linear-gradient(180deg, rgba(21, 128, 61, 0.08), #ffffff);
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.quick-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.quick-card:hover {
  border-color: rgba(var(--accent-rgb), 0.55);
  background: var(--panel-2);
  transform: translateY(-2px);
}
.quick-card strong {
  display: block;
  margin-bottom: 6px;
}
.quick-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.home-tile {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.home-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb), 0.55);
  background: var(--panel-2);
}
.home-tile strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.05rem;
}
.home-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.home-tile-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}
.home-tile-icon-green {
  background: rgba(21, 128, 61, 0.12);
  color: #15803d;
}
.home-tile-icon-amber {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}
.home-tile-icon-purple {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
}
.home-note {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
}
.home-note h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--accent);
}
.home-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.panel h3 { margin-top: 0; }

.chart-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
}
.bar-track {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff6a3d);
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.period-select {
  min-width: 180px;
}
.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
}
.inline-form {
  display: inline;
  margin: 0;
}
.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.btn-link.unlock { color: #15803d; }
.btn-link.lock { color: #b45309; }
input, select, button, .btn {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  text-decoration: none;
  display: inline-block;
}
button, .btn { cursor: pointer; }
button.primary, .btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: white;
}
button.primary:hover, .btn.primary:hover {
  background: #ff5530;
}
a.link {
  color: var(--accent);
  text-decoration: none;
}
a.link:hover { text-decoration: underline; }

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  max-width: 100%;
  max-height: none;
  scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: #b0b0b0;
  border-radius: 8px;
}
.table-wrap::-webkit-scrollbar-track {
  background: #ececec;
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 0.85rem; }
tbody tr:hover { background: rgba(var(--accent-rgb), 0.08); }

.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.detail-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 18px;
}
.detail-grid div span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.flight-html {
  background: white;
  color: #111;
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
  max-height: 320px;
}
.comment {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.section-header h3 { margin: 0; }
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.comment-form textarea {
  width: 100%;
  min-height: 90px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  resize: vertical;
}

.user-panel {
  padding: 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.user-name { font-weight: 600; }
.user-role { color: var(--muted); font-size: 0.85rem; margin: 4px 0 10px; }
.logout-btn {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.logout-btn:hover { border-color: var(--accent); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
}
.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}
.login-brand h1 { margin: 0; font-size: 1.25rem; }
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.login-card label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
}
.login-card input[type="text"],
.login-card input[type="password"],
.login-card select.login-portal {
  width: 100%;
}
.login-card select.login-portal {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
}
.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
}
.login-btn {
  width: 100%;
  margin-top: 18px;
}
.validation-summary {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.login-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.login-hint code {
  color: var(--accent);
}

.field-validation-error { color: #991b1b; font-size: 0.85rem; }

.breadcrumb {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.breadcrumb a,
.breadcrumb span {
  display: inline;
  white-space: nowrap;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb a:hover {
  text-decoration: underline;
}

.booking-form { display: flex; flex-direction: column; gap: 16px; }

.form-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  padding:10px;
}
.form-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(90deg, #b8320f, var(--accent));
  color: white;
  font-weight: 600;
}
.section-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}
.form-section > .form-grid,
.form-section > .form-field,
.form-section > #passenger-list {
  padding: 18px;
}
.form-section > .form-field:first-of-type { padding-bottom: 0; }
.form-section > .form-grid:last-child { padding-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 700px) {
  .form-grid .span-2 { grid-column: span 1; }
}

.form-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
}
.form-field textarea { resize: vertical; min-height: 80px; }
.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}
.ref-readonly {
  color: var(--accent-2);
  font-weight: 600;
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.3);
}

.dob-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.passenger-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.passenger-block:last-child { border-bottom: none; padding-bottom: 0; }
.passenger-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.submit-booking {
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
}
.validation-summary { margin-bottom: 0; }

.success-alert {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  background: rgba(21, 128, 61, 0.1);
  border: 1px solid var(--accent-2);
  color: #14532d;
}

.booking-list-card > .booking-search,
.booking-list-card > .booking-table-wrap,
.booking-list-card > .table-footer {
  padding: 18px;
}
.booking-search .search-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}
.search-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.booking-table-wrap { border: none; background: transparent; }
.booking-table { font-size: 0.85rem; }
.booking-table th {
  white-space: nowrap;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.booking-table td { vertical-align: middle; }
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-warning { background: rgba(217, 119, 6, 0.12); color: #92400e; border: 1px solid rgba(217, 119, 6, 0.35); }
.badge-success { background: rgba(21, 128, 61, 0.12); color: #14532d; border: 1px solid rgba(21, 128, 61, 0.35); }
.badge-danger { background: rgba(220, 38, 38, 0.1); color: #991b1b; border: 1px solid rgba(220, 38, 38, 0.35); }
.badge-info { background: rgba(var(--accent-rgb), 0.12); color: #9a3412; border: 1px solid rgba(var(--accent-rgb), 0.35); }
.badge-muted { background: rgba(100, 100, 100, 0.08); color: var(--muted); border: 1px solid var(--border); }

.action-icons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0;
}
.icon-btn.view { background: rgba(251, 191, 36, 0.15); }
.icon-btn.edit { background: rgba(var(--accent-rgb), 0.15); }
.icon-btn.upload { background: rgba(var(--accent-rgb), 0.15); }
.icon-btn.comment { background: rgba(45, 212, 191, 0.15); }
.attach-count {
  font-size: 0.75rem;
  color: var(--accent-2);
  font-weight: 600;
}

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.modal-card {
  position: relative;
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  z-index: 1;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.modal-header h3 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
}
.modal-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.view-booking .form-section > .form-grid,
.view-booking .form-section > .view-field,
.view-booking .form-section > .section-body,
.view-booking .form-section > .passenger-block {
  padding: 18px;
}
.view-booking .form-section > .view-field:first-child { padding-bottom: 0; }
.view-booking .passenger-block {
  border-bottom: 1px solid var(--border);
  padding-top: 0;
}
.view-booking .passenger-block:last-child { border-bottom: none; }

.view-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}
.view-value {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  word-break: break-word;
}
.view-value.view-textarea {
  min-height: 80px;
  white-space: pre-wrap;
}
.section-empty {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
}
.section-body { padding: 18px; }

.attachment-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.attachment-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.attachment-thumb,
.attachment-file {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  text-decoration: none;
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-thumb.broken-image {
  background: rgba(var(--accent-rgb), 0.1);
}
.attachment-thumb.broken-image::after {
  content: "Image";
  color: var(--muted);
  font-size: 0.85rem;
}
.file-icon { font-size: 2rem; }
.attachment-name {
  color: var(--accent);
  font-size: 0.8rem;
  text-align: center;
  word-break: break-all;
  text-decoration: none;
}
.upload-inline-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.nav-section {
  margin-top: 14px;
  padding: 8px 14px 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-group {
  border: 1px solid transparent;
  border-radius: 12px;
}
.nav-group-title {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}
.nav-group:not([open]) .nav-group-title::after {
  transform: rotate(-90deg);
}
.nav-group-title:hover {
  background: var(--panel-2);
  border: 1px solid var(--border);
  margin: 0 -1px;
  padding-left: 15px;
  padding-right: 15px;
}
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 8px 10px;
  border-left: 2px solid var(--border);
  margin: 0 0 4px 14px;
}
.nav-sub .nav-link {
  padding: 10px 12px;
  font-size: 0.92rem;
}

.muted { color: var(--muted); }
.row-muted { opacity: 0.65; }
.row-holiday td:first-child { color: #6d28d9; }
.field-error { color: #991b1b; font-size: 0.8rem; }
.attendance-form .form-grid { margin-top: 8px; }

.att-calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
}
.att-cal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.att-cal-head h3 { margin: 0; }
.att-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.att-cal-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.att-cal-legend .dot.present { background: #22c55e; }
.att-cal-legend .dot.wfh { background: #ed4214; }
.att-cal-legend .dot.half { background: #fbbf24; }
.att-cal-legend .dot.leave { background: #94a3b8; }
.att-cal-legend .dot.absent { background: #f87171; }
.att-cal-legend .dot.holiday { background: #a78bfa; }

.att-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.att-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.att-cal-cell {
  min-height: 72px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  padding: 8px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.att-cal-cell.empty {
  background: transparent;
  border-color: transparent;
  min-height: 72px;
}
.att-cal-cell.day:not(.disabled):hover {
  border-color: rgba(var(--accent-rgb), 0.65);
  transform: translateY(-1px);
}
.att-cal-cell.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.45);
}
.att-cal-cell.is-today .day-num {
  color: var(--accent);
  font-weight: 700;
}
.att-cal-cell.disabled {
  opacity: 0.45;
  cursor: default;
}
.att-cal-cell .day-num {
  font-size: 0.95rem;
  font-weight: 600;
}
.att-cal-cell .day-status {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.att-cal-cell.present { background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.35); }
.att-cal-cell.wfh { background: rgba(var(--accent-rgb), 0.16); border-color: rgba(var(--accent-rgb), 0.4); }
.att-cal-cell.half { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.35); }
.att-cal-cell.leave { background: rgba(148, 163, 184, 0.14); border-color: rgba(148, 163, 184, 0.35); }
.att-cal-cell.absent { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.35); }
.att-cal-cell.holiday { background: rgba(167, 139, 250, 0.14); border-color: rgba(167, 139, 250, 0.35); }
.att-cal-cell.weekend { opacity: 0.55; }

.att-mark-panel h3 { margin-top: 0; }

.opt-toggle-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  margin-top: 8px;
}
.opt-toggle-panel .opt-state {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.opt-toggle-panel .opt-state.opted-in { color: #14532d; }
.opt-toggle-panel .opt-state.opted-out { color: #64748b; }
.opt-btn {
  width: 100%;
  min-height: 52px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.opt-btn-in { background: #15803d; border-color: #15803d; }
.opt-btn-in:hover { background: #166534; border-color: #166534; }
.opt-btn-out { background: #b45309; border-color: #b45309; }
.opt-btn-out:hover { background: #92400e; border-color: #92400e; }
.opt-btn-done {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #64748b;
  cursor: default;
}
.opt-action-form { margin: 0; }
.opt-toggle-panel .form-field { margin-bottom: 4px; }
.opt-toggle-panel .form-field label { display: block; margin-bottom: 4px; font-size: 0.9rem; }

.month-day-scroll { overflow-x: auto; }
.month-day-grid {
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 100%;
}
.month-day-grid th,
.month-day-grid td {
  text-align: center;
  padding: 4px 2px;
  min-width: 28px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.month-day-grid .sticky-col {
  position: sticky;
  left: 0;
  background: var(--panel, #fff);
  text-align: left;
  padding: 6px 10px;
  min-width: 160px;
  z-index: 1;
  white-space: nowrap;
}
.month-day-grid .day-num-col { font-weight: 600; color: #64748b; }
.month-day-grid .day-cell.present { background: rgba(34, 197, 94, 0.18); color: #14532d; font-weight: 600; }
.month-day-grid .day-cell.wfh { background: rgba(59, 130, 246, 0.16); color: #1e40af; font-weight: 600; }
.month-day-grid .day-cell.half { background: rgba(251, 191, 36, 0.2); color: #92400e; font-weight: 600; }
.month-day-grid .day-cell.leave { background: rgba(148, 163, 184, 0.2); color: #475569; font-weight: 600; }
.month-day-grid .day-cell.absent { background: rgba(248, 113, 113, 0.2); color: #991b1b; font-weight: 600; }
.month-day-grid .day-cell.wknd { background: rgba(148, 163, 184, 0.08); color: #94a3b8; }
.month-day-grid .day-cell.hol { background: rgba(167, 139, 250, 0.14); color: #6d28d9; }

/* ---- Responsive ---- */
@media (max-width: 980px) {
  .att-calendar-layout { grid-template-columns: 1fr; }
  .att-cal-cell { min-height: 64px; }
  .panels { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
  }
  body.no-scroll {
    overflow: hidden;
    touch-action: none;
  }

  .app {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: auto;
    overflow: visible;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 14px;
    background: #efefef;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .menu-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 10px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    flex-shrink: 0;
  }
  .menu-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text);
    border-radius: 2px;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .mobile-brand strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.2;
  }
  .mobile-brand span:not(.brand-mark) {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
  }
  .brand-mark.sm {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 0.75rem;
    box-shadow: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .app.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 60;
    border-right: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.12);
  }
  .app.nav-open .sidebar { transform: translateX(0); }

  .sidebar-close {
    display: grid;
    place-items: center;
    margin-left: auto;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
  }

  .content {
    padding: 18px 14px 28px;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .panel,
  .detail-card,
  .form-section,
  .booking-list-card,
  .stat-card,
  .welcome-banner {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page-header h2 { font-size: 1.45rem; }
  .page-header.row { align-items: stretch; }
  .page-header.row > a.btn,
  .page-header.row > .btn,
  .page-header.row > button {
    width: 100%;
    text-align: center;
  }

  .welcome-banner {
    padding: 20px 18px;
    align-items: flex-start;
  }
  .welcome-meta { text-align: left; min-width: 0; }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filters > *,
  .period-select,
  .filters input,
  .filters select,
  .filters .btn,
  .filters button {
    width: 100%;
    min-width: 0;
  }

  .row-actions {
    flex-wrap: wrap;
    white-space: normal;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 { grid-column: span 1; }

  .dob-row {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .quick-actions,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .search-actions {
    flex-direction: column;
  }
  .search-actions .btn,
  .search-actions button {
    width: 100%;
    text-align: center;
  }

  .table-footer {
    flex-direction: column;
    align-items: stretch;
  }

  th, td { padding: 10px 12px; }

  /* Easy horizontal + vertical swipe for wide/tall content on mobile */
  .table-wrap,
  .booking-table-wrap,
  .breadcrumb,
  .row-actions,
  .att-cal-scroll,
  .filters,
  .flight-html,
  .form-section,
  .panel {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
    touch-action: pan-x pan-y;
    scrollbar-width: auto;
  }
  .table-wrap::-webkit-scrollbar,
  .booking-table-wrap::-webkit-scrollbar,
  .att-cal-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  .table-wrap::-webkit-scrollbar-thumb,
  .booking-table-wrap::-webkit-scrollbar-thumb,
  .att-cal-scroll::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 10px;
  }
  .table-wrap::-webkit-scrollbar-track,
  .booking-table-wrap::-webkit-scrollbar-track,
  .att-cal-scroll::-webkit-scrollbar-track {
    background: #e4e4e4;
  }

  .row-actions {
    flex-wrap: nowrap;
    white-space: nowrap;
    max-width: 100%;
    padding-bottom: 4px;
  }

  .filters {
    max-width: 100%;
  }

  .att-calendar {
    overflow: auto;
  }
  .att-cal-scroll {
    width: 100%;
    max-width: 100%;
    padding-bottom: 6px;
  }
  .att-cal-scroll .att-cal-weekdays,
  .att-cal-scroll .att-cal-grid {
    min-width: 420px;
  }

  .att-cal-cell {
    min-height: 52px;
    padding: 6px;
    border-radius: 8px;
  }
  .att-cal-cell.empty { min-height: 52px; }
  .att-cal-cell .day-status { font-size: 0.62rem; }
  .att-cal-weekdays { font-size: 0.7rem; gap: 4px; }
  .att-cal-grid { gap: 4px; }
}

@media (max-width: 480px) {
  .content {
    padding: 14px 10px 24px;
    overflow-x: auto;
    overflow-y: visible;
  }

  .page-header h2 { font-size: 1.3rem; }

  .login-body {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
  }
  .login-card { padding: 20px 16px; border-radius: 16px; margin: 12px 0; }

  .att-cal-cell .day-status { display: none; }
  .att-cal-cell {
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 4px;
  }
  .att-cal-cell .day-num { font-size: 0.85rem; }
  .att-cal-legend { font-size: 0.7rem; gap: 8px; }

  table { min-width: 640px; }
  .btn, button, input, select {
    font-size: 1rem; /* avoid iOS zoom on focus */
  }

  .pagination { flex-wrap: wrap; gap: 8px; }

  .table-wrap,
  .booking-table-wrap,
  .att-cal-scroll {
    padding-bottom: 2px;
  }
}
