
/* Login / Register tabs — equal width containers */
.auth-tabs {
  display: flex;
  width: 100%;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  padding: 0.3rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-sizing: border-box;
}
.auth-tab {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  padding: 0.7rem 0.5rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
html[data-theme="light"] .auth-tab.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,0.1);
}
.auth-tab:not(.active):hover {
  color: var(--text);
}

:root {
  --bg-dark: #0a0f1a;
  --bg-card: #121a2b;
  --bg-input: #1a2438;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-dim: rgba(34, 197, 94, 0.15);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --success: #22c55e;
}

html[data-theme="light"] {
  --bg-dark: #f1f5f9;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-dim: rgba(22, 163, 74, 0.12);
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --success: #16a34a;
}

html[data-theme="light"] body {
  background: var(--bg-dark);
  color: var(--text);
}

html[data-theme="light"] .bg-overlay {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(22, 163, 74, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(37, 99, 235, 0.04) 0%, transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

html[data-theme="light"] .bg-overlay::before,
html[data-theme="light"] .bg-overlay::after {
  opacity: 0.15;
}

html[data-theme="light"] .login-card,
html[data-theme="light"] .card,
html[data-theme="light"] .report-card,
html[data-theme="light"] .modal-content {
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom-color: var(--border);
}

html[data-theme="light"] .nav-tabs {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--border);
}

html[data-theme="light"] .nav-tab.active {
  background: var(--accent-dim);
}

html[data-theme="light"] .stat-card {
  background: var(--bg-card);
  border-color: var(--border);
}

html[data-theme="light"] .table th {
  background: #f1f5f9;
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border);
}

.btn-theme {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-theme:hover {
  border-color: var(--accent);
  color: var(--accent);
}



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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
}

/* Background with cameras/sensors theme */
.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(34, 197, 94, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, #0a0f1a 0%, #0d1525 100%);
  background-size: cover;
}

.bg-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%231e293b' stroke-width='0.5' opacity='0.4'%3E%3Ccircle cx='40' cy='40' r='12'/%3E%3Ccircle cx='40' cy='40' r='6'/%3E%3Cpath d='M40 10v8M40 62v8M10 40h8M62 40h8'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.bg-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%231e293b' opacity='0.25'%3E%3Cpath d='M60 20c-8 0-15 7-15 15v10h-8c-4 0-8 4-8 8v30c0 4 4 8 8 8h46c4 0 8-4 8-8V53c0-4-4-8-8-8h-8V35c0-8-7-15-15-15zm0 8c4 0 7 3 7 7v10H53V35c0-4 3-7 7-7z'/%3E%3Ccircle cx='60' cy='72' r='6'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px;
  opacity: 0.3;
}

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* LOGIN */
#login-screen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

#login-screen.active {
  display: flex;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo i {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.logo img {
  display: block;
  margin: 0 auto 0.75rem;
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: contain;
  background: transparent;
  border: none;
  box-shadow: none;
}

.header-left img {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.lang-select {
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.lang-select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #052e16;
}

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

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

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

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.demo-accounts {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.demo-accounts code {
  background: var(--bg-input);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent);
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: rgba(18, 26, 43, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-left i {
  color: var(--accent);
  font-size: 1.4rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#user-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* NAV */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.nav-tab {
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--bg-input);
}

.nav-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* MAIN */
.main-content {
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section h2 {
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section h2 i {
  color: var(--accent);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.card h3 {
  font-size: 1.05rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* TABLE */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
}

.table tr:last-child td {
  border-bottom: none;
}

/* REPORT CARDS */
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}

.report-card:hover {
  border-color: #334155;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.report-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-approved {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge-rejected {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.badge-paid {
  background: rgba(59, 130, 246, 0.2);
  color: var(--info);
}

.report-items {
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.report-items li {
  margin-bottom: 0.25rem;
  list-style: none;
  padding-left: 0;
}

.report-total {
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.5rem;
}

.report-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.photo-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0.25rem;
  cursor: pointer;
  border: 1px solid var(--border);
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.work-row {
  display: grid;
  grid-template-columns: 1fr 80px 40px;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.work-row select,
.work-row input {
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--text);
}

.edit-history {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 0.85rem;
}

.edit-history h4 {
  margin-bottom: 0.5rem;
  color: var(--warning);
}

.edit-item {
  margin-bottom: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.edit-item:last-child {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* ========== RESPONSIVE / MOBILE ========== */

/* Tablets and below */
@media (max-width: 768px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .brand {
    font-size: 1rem;
  }

  .nav-tabs {
    padding: 0.5rem 0.75rem;
    gap: 0.2rem;
    -webkit-overflow-scrolling: touch;
  }

  .nav-tab {
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
  }

  .nav-tab i {
    margin-right: 0.25rem;
  }

  .main-content {
    padding: 1rem;
  }

  .section h2 {
    font-size: 1.2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-card .value {
    font-size: 1.4rem;
  }

  .stat-card .label {
    font-size: 0.8rem;
  }

  .card {
    padding: 1rem;
  }

  .table th,
  .table td {
    padding: 0.6rem 0.4rem;
    font-size: 0.85rem;
  }

  .report-card {
    padding: 1rem;
  }

  .report-actions {
    flex-direction: column;
  }

  .report-actions .btn {
    width: 100%;
  }

  .modal-content {
    padding: 1.25rem;
    max-height: 85vh;
    border-radius: 12px 12px 0 0;
    margin-top: auto;
  }

  .photo-thumb {
    width: 70px;
    height: 70px;
  }
}

/* Phones */
@media (max-width: 640px) {
  .login-card {
    padding: 1.75rem 1.25rem;
    border-radius: 12px;
  }

  .logo i {
    font-size: 2.5rem;
  }

  .logo h1 {
    font-size: 1.5rem;
  }

  .header {
    flex-direction: column;
    gap: 0.6rem;
    align-items: stretch;
  }

  .header-left,
  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .header-right {
    flex-wrap: wrap;
  }

  #user-info {
    font-size: 0.85rem;
    flex: 1;
  }

  .nav-tabs {
    padding: 0.4rem 0.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
    background: rgba(18, 26, 43, 0.98);
    backdrop-filter: blur(8px);
  }

  .nav-tab {
    padding: 0.5rem 0.65rem;
    font-size: 0.75rem;
    flex-shrink: 0;
  }

  /* Hide text on very small, keep icons if needed — but keep labels for clarity */
  .nav-tab i {
    display: inline-block;
  }

  .main-content {
    padding: 0.85rem 0.75rem 5rem; /* extra bottom space for sticky nav feel */
  }

  .section h2 {
    font-size: 1.15rem;
    margin-bottom: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .stat-card .value {
    font-size: 1.25rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 0.85rem 0.9rem; /* larger touch targets */
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .btn {
    padding: 0.85rem 1.1rem;
    font-size: 0.95rem;
    min-height: 44px; /* Apple touch target guideline */
  }

  .btn-sm {
    padding: 0.55rem 0.9rem;
    min-height: 40px;
  }

  .work-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .work-row select,
  .work-row input {
    padding: 0.75rem;
    font-size: 16px;
    width: 100%;
  }

  .work-row .btn-remove-work {
    width: 100%;
    justify-content: center;
  }

  .filters {
    flex-direction: column;
  }

  .filters select {
    width: 100%;
    padding: 0.75rem;
    font-size: 16px;
  }

  .report-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .report-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .photo-thumb {
    width: 64px;
    height: 64px;
  }

  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table th,
  .table td {
    white-space: nowrap;
    font-size: 0.8rem;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    padding: 1.25rem 1rem 2rem;
  }

  .modal-close {
    top: 0.75rem;
    right: 1rem;
    font-size: 1.75rem;
    padding: 0.25rem;
  }

  .demo-accounts {
    font-size: 0.75rem;
  }

  .demo-accounts code {
    font-size: 0.7rem;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .nav-tab {
    padding: 0.45rem 0.5rem;
    font-size: 0.7rem;
  }

  .login-card {
    padding: 1.5rem 1rem;
  }
}

/* Improve touch scrolling and prevent pull-to-refresh issues on some browsers */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-overflow-scrolling: touch;
}

/* Safe area for notched phones (iPhone X+) */
@supports (padding: max(0px)) {
  .header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .nav-tabs {
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
  }

  .main-content {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: max(5rem, env(safe-area-inset-bottom));
  }

  .modal-content {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
}


/* ========== UI polish 2026-09 ========== */
.nav-tabs {
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg-card);
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: sticky;
  top: 52px;
  z-index: 50;
}

.filters .form-group {
  margin: 0;
  min-width: 120px;
  flex: 1 1 120px;
}
.filters .form-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
  display: block;
  color: var(--text-muted);
}
.filters select,
.filters input[type="date"],
.filters input[type="month"] {
  width: 100%;
  min-height: 40px;
}

.report-card {
  padding: 0.9rem 1rem;
  margin-bottom: 0.65rem;
}
.report-header {
  gap: 0.5rem;
}
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}
.report-actions .btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  min-height: 36px;
}

.stats-grid {
  gap: 0.65rem;
}
.stat-card {
  padding: 0.85rem 1rem;
  border-radius: 12px;
}
.stat-card .value {
  font-size: 1.35rem;
}

.section h2 {
  font-size: 1.2rem;
  margin-bottom: 0.9rem;
}

.main-content {
  padding: 1rem 1.1rem 4rem;
}

/* Compact header */
.header {
  padding: 0.65rem 1rem;
  gap: 0.5rem;
}
.header-right {
  gap: 0.45rem;
  flex-wrap: wrap;
}
#user-info {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-select {
  min-height: 36px;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
}

html[data-theme="light"] .nav-tabs,
html[data-theme="light"] .filters {
  background: #fff;
}

@media (max-width: 768px) {
  .header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .header-left {
    flex: 1;
    min-width: 0;
  }
  .header-right {
    width: auto;
    margin-left: auto;
  }
  #user-info {
    display: none; /* name in brand area enough on phone; less clutter */
  }
  .nav-tabs {
    top: 0;
    padding: 0.35rem 0.4rem;
    gap: 0.15rem;
  }
  .nav-tab {
    padding: 0.45rem 0.55rem;
    font-size: 0.72rem;
    border-radius: 8px;
  }
  .filters {
    top: 44px;
    padding: 0.55rem;
    gap: 0.4rem;
  }
  .main-content {
    padding: 0.75rem 0.65rem 5rem;
  }
  .report-actions .btn {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 0;
  }
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Bottom nav feel: pad last content */
#app-screen {
  padding-bottom: env(safe-area-inset-bottom, 0);
}


/* ========== Compact dropdown nav ========== */
.nav-tabs {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  overflow: visible;
}

.nav-main-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  white-space: nowrap;
}
.nav-main-btn:hover {
  color: var(--text);
  background: var(--bg-input);
}
.nav-main-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.nav-caret {
  font-size: 0.7rem;
  opacity: 0.7;
}

.nav-drop {
  position: relative;
}
.nav-drop-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  padding: 0.35rem;
  z-index: 200;
}
.nav-drop.open .nav-drop-panel {
  display: block;
}
.nav-drop-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}
.nav-drop-item:hover {
  background: var(--bg-input);
}
.nav-drop-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}

html[data-theme="light"] .nav-drop-panel {
  background: #fff;
  box-shadow: 0 12px 28px rgba(15,23,42,0.12);
}

@media (max-width: 640px) {
  .nav-tabs {
    justify-content: space-between;
    padding: 0.35rem 0.4rem;
  }
  .nav-main-btn {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.35rem;
    font-size: 0.72rem;
    flex-direction: column;
    gap: 0.15rem;
  }
  .nav-main-btn .nav-caret {
    display: none;
  }
  .nav-drop-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    min-width: 0 !important;
    width: 100% !important;
    max-height: 55vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0 !important;
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 0.5rem 0.5rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 32px rgba(0,0,0,0.35);
    animation: navSheetUp 0.22s ease-out;
  }
  .nav-drop-head {
    padding: 0.5rem 0.75rem 0.65rem;
  }
  .nav-drop-item {
    padding: 0.85rem 0.9rem;
    font-size: 1rem;
  }
}
@keyframes navSheetUp {
  from { transform: translateY(100%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}


/* Force dropdown nav visible (override older overflow rules) */
.nav-tabs {
  overflow: visible !important;
  overflow-x: visible !important;
  position: relative;
  z-index: 120;
}
.nav-drop-panel {
  display: none;
}
.nav-drop.open > .nav-drop-panel {
  display: block !important;
}


/* Nav close + equal buttons */
.nav-caret-hidden {
  visibility: hidden;
  width: 0.7rem;
}
.nav-drop-link .nav-main-btn {
  /* same as toggles */
}
.nav-drop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.nav-drop-close {
  border: none;
  background: var(--bg-input);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.nav-drop-close:hover {
  background: var(--danger);
  color: #fff;
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 110;
}
.nav-backdrop.show {
  display: block;
}
.nav-tabs {
  z-index: 130;
  position: relative;
}
.nav-drop.open .nav-drop-panel {
  z-index: 140;
}




/* Period report 2x2 filter grid */
.period-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 0.85rem;
  align-items: end;
  margin-bottom: 0.25rem;
}
.period-filter-grid .period-cell {
  margin: 0;
  min-width: 0;
}
.period-filter-grid .period-cell label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.period-filter-grid .period-cell select,
.period-filter-grid .period-cell input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  font-size: 16px;
  box-sizing: border-box;
}
/* iOS/Android date inputs can expand past grid — clip them */
.period-filter-grid .period-cell input[type="date"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  display: block;
}
.period-filter-grid {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
#section-period .card {
  overflow: hidden;
}
.period-filter-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
}
.period-filter-actions .btn {
  flex: 1;
  min-height: 44px;
}
.period-results {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.period-results:empty {
  display: none;
}
@media (min-width: 720px) {
  .period-filter-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
  .period-filter-actions {
    grid-column: 1 / -1;
  }
}


/* ===== FORCE bottom sheet menu on phones (must be last) ===== */
@media (max-width: 900px) {
  .nav-drop.open > .nav-drop-panel,
  .nav-drop.open .nav-drop-panel {
    display: block !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    border: 1px solid var(--border) !important;
    border-bottom: none !important;
    padding: 0.55rem 0.55rem calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.45) !important;
    z-index: 9999 !important;
    animation: navSheetUp 0.22s ease-out;
  }
  .nav-backdrop.show {
    display: block !important;
    z-index: 9990 !important;
  }
  .nav-drop-item {
    padding: 0.9rem 1rem !important;
    font-size: 1.05rem !important;
  }
}

/* Bottom sheet panel attached to body */
.nav-drop-panel.nav-sheet-portaled {
  display: block !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100% !important;
  max-height: 60vh !important;
  overflow-y: auto !important;
  border-radius: 18px 18px 0 0 !important;
  border: 1px solid var(--border) !important;
  border-bottom: none !important;
  padding: 0.55rem 0.55rem calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.45) !important;
  z-index: 10000 !important;
  background: var(--bg-card) !important;
  animation: navSheetUp 0.22s ease-out;
}
html[data-theme="light"] .nav-drop-panel.nav-sheet-portaled {
  background: #fff !important;
}


/* iPhone notch / Dynamic Island — keep header below status bar */
.header {
  padding-top: max(0.65rem, env(safe-area-inset-top, 0px)) !important;
  padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
}
.nav-tabs {
  top: 0;
}
#app-screen {
  padding-top: 0;
}
/* Extra top gap on notched phones for sticky nav under header */
@supports (padding: max(0px)) {
  .header {
    padding-top: max(0.85rem, calc(env(safe-area-inset-top, 0px) + 0.35rem)) !important;
  }
}

/* SEO intro on login page */
.seo-intro {
  max-width: 520px;
  margin: 1rem auto 0;
  padding: 1rem 1.1rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
  position: relative;
  z-index: 2;
}
.seo-intro h1 {
  font-size: 1.25rem;
  color: var(--text);
  margin: 0 0 0.6rem;
  line-height: 1.35;
}
.seo-intro p { margin: 0 0 0.75rem; }
.seo-intro ul { margin: 0 0 0.5rem; padding-left: 1.15rem; }
.seo-intro li { margin-bottom: 0.35rem; }
#app-screen.active ~ .seo-intro,
body:has(#app-screen.active) .seo-intro { display: none; }
@media (max-width: 480px) {
  .seo-intro { padding: 0.75rem 0.9rem 0; font-size: 0.85rem; }
  .seo-intro h1 { font-size: 1.05rem; }
}

.seo-intro { display: none !important; }

/* Period report filters: 2x2 grid */
.period-filters {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  align-items: end;
}
.period-filters .form-group {
  margin: 0 !important;
  min-width: 0;
}
.period-filters .form-group label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.period-filters select,
.period-filters input[type="date"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.period-filters-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
@media (max-width: 420px) {
  .period-filters {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 0.5rem;
  }
}

/* Date inputs never overflow period filter grid */
.period-filters,
.period-filter-grid {
  overflow: hidden !important;
  width: 100% !important;
  max-width: 100% !important;
}
.period-filters .form-group,
.period-filter-grid .period-cell {
  overflow: hidden !important;
  min-width: 0 !important;
  max-width: 100% !important;
}
.period-filters input[type="date"],
.period-filter-grid input[type="date"] {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  font-size: 16px !important;
  padding: 0.55rem 0.4rem !important;
}
#section-period .card {
  overflow: hidden !important;
  max-width: 100%;
}
@media (max-width: 768px) {
  .filters.period-filters {
    flex-direction: unset !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
  }
}

.file-pick-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.file-pick-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* Period report — same visual rhythm as All reports */
#section-period .filters.period-filters {
  margin-bottom: 1rem;
}
#period-summary.card h3 {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-weight: 600;
}
#period-summary .stats-grid {
  margin-top: 0.35rem;
}

#verify-email-screen { display: none; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
#verify-email-screen.active { display: flex; }


/* ===== Splash intro (site + PWA) ===== */
#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0f172a 0%, #020617 70%, #000 100%);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}
#splash-screen.splash-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem;
}
.splash-icon-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashIconIn 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.splash-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: cover;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.25), 0 12px 40px rgba(0,0,0,0.45);
}
.splash-glow {
  position: absolute;
  inset: -20%;
  border-radius: 30px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.45) 0%, rgba(56, 189, 248, 0.2) 40%, transparent 70%);
  filter: blur(12px);
  z-index: 1;
  animation: splashGlowPulse 1.8s ease-in-out infinite;
}
.splash-text {
  margin-top: 1.35rem;
  opacity: 0;
  transform: translateY(12px);
  animation: splashTextIn 0.7s ease 0.85s forwards;
}
.splash-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.02em;
}
.splash-sub {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: #94a3b8;
}
@keyframes splashIconIn {
  0% { transform: scale(1.55); opacity: 0.3; filter: blur(4px); }
  50% { transform: scale(0.96); opacity: 1; filter: blur(0); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}
@keyframes splashGlowPulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes splashTextIn {
  to { opacity: 1; transform: translateY(0); }
}

/* While splash runs, soft-hide login content then reveal */
body.splash-pending #login-screen .login-card > *:not(.logo) {
  opacity: 0;
  transform: translateY(10px);
}
body.splash-done #login-screen .login-card > *:not(.logo) {
  animation: splashFormIn 0.55s ease forwards;
}
body.splash-done #login-screen .login-card > .logo { opacity: 1; }
body.splash-done #login-screen .auth-tabs { animation-delay: 0.05s; }
body.splash-done #login-screen form { animation-delay: 0.12s; }
@keyframes splashFormIn {
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  #splash-screen { display: none !important; }
  body.splash-pending #login-screen .login-card > * { opacity: 1; transform: none; }
}


.lang-theme-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.lang-theme-row .btn-theme { flex-shrink: 0; }
#btn-about-login { min-width: 7.5rem; }
