@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
/* LLM Lens–inspired: dark slate surfaces, light content, clean cards */
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f1f5f9; color: #0f172a; overflow-x: hidden; }
a { color: #0ea5e9; text-decoration: none; }
a:hover { text-decoration: underline; }
/* Touch-friendly: 44px minimum tap targets, reduce tap highlight */
@media (hover: none) {
  .btn, .btn-outline, button, a.btn { -webkit-tap-highlight-color: transparent; }
}

/* Login – LLM Lens style: dark surface, clean card */
.login-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  background: #0f172a;
  padding: 1rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: max(1rem, env(safe-area-inset-bottom));
}
.login-page .app-brand-top { flex-shrink: 0; }
.login-page .login-box { margin: auto; }

.login-box {
  background: #fff;
  padding: 1.5rem 1.75rem;
  border-radius: 12px;
  width: 100%; max-width: 380px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 25px 50px -12px rgba(0,0,0,0.25);
  border: 1px solid #e2e8f0;
  position: relative;
}
.login-box::before {
  content: '';
  position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  background: linear-gradient(180deg, #0ea5e9, #06b6d4);
  border-radius: 12px 0 0 12px;
}
.login-box h1 {
  margin: 0 0 1rem;
  font-size: 1.375rem;
  font-weight: 600;
  text-align: center;
  color: #0f172a;
  letter-spacing: -0.025em;
}
.login-box label { display: block; margin-bottom: 0.375rem; font-size: 0.8125rem; font-weight: 600; color: #475569; }
.login-box input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  margin-bottom: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 16px;
  min-height: 44px;
  background: #f8fafc;
  color: #0f172a;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:hover { border-color: #cbd5e1; }
.login-box input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  background: #fff;
}
.login-box button {
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 44px;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.2s, opacity 0.2s;
}
.login-box button:hover { background: #1e293b; }
.login-box button:active { opacity: 0.9; }
.login-password-row { }
.login-password-wrap { position: relative; }
.login-password-wrap input { width: 100%; padding-right: 2.5rem; box-sizing: border-box; }
.login-pwd-toggle { position: absolute; top: 50%; right: 0.625rem; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; padding: 0.25rem; color: #64748b; cursor: pointer; border: none; background: none; }
.login-pwd-toggle:hover { color: #0f172a; }
.login-pwd-toggle .login-pwd-icon { display: block; }
.login-pwd-toggle .login-pwd-icon-hide { display: none; }
.login-pwd-toggle.is-visible .login-pwd-icon-show { display: none; }
.login-pwd-toggle.is-visible .login-pwd-icon-hide { display: block; }
.login-otp-row { margin-top: 0.75rem; }
.login-otp-row input { width: 6rem; }
.login-otp-hint { font-size: 0.875rem; color: #475569; margin: 0 0 0.5rem; }
.login-start-over { margin-top: 0.75rem; font-size: 0.875rem; }
.login-start-over a { color: #64748b; text-decoration: none; }
.login-start-over a:hover { text-decoration: underline; }
.login-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.login-actions button { flex: 1; min-width: 0; }
.login-submit-btn.is-loading { pointer-events: none; cursor: wait; }
.login-submit-btn.is-loading .login-btn-spinner { display: inline-block; vertical-align: middle; margin-right: 0.5rem; }
.login-btn-spinner { width: 1rem; height: 1rem; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: login-spin 0.7s linear infinite; }
@keyframes login-spin { to { transform: rotate(360deg); } }
.login-add-record { margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid #e2e8f0; text-align: center; }
.login-add-record .login-add-btn {
  display: inline-block; width: 100%;
  padding: 0.625rem 1rem;
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9375rem; font-weight: 600;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}
.login-add-record .login-add-btn:hover { background: #f1f5f9; border-color: #94a3b8; text-decoration: none; }
.error-msg { color: #dc2626; font-size: 0.875rem; margin-bottom: 1rem; text-align: center; font-weight: 500; }

/* App brand (logo + name) */
.app-brand { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.app-brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.app-brand-name { font-size: 1rem; font-weight: 700; white-space: nowrap; letter-spacing: -0.02em; }
.header .app-brand-name { color: #fff; }
.app-brand-top {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  padding: 1.25rem 1rem; padding-top: max(1.25rem, env(safe-area-inset-top));
  background: #0f172a;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app-brand-top .app-brand-logo { width: 56px; height: 56px; border-radius: 8px; }
.app-brand-top .app-brand-name { font-size: 1.25rem; font-weight: 600; color: #fff; letter-spacing: -0.02em; }

/* Dashboard – LLM Lens style */
.dashboard-page { min-height: 100vh; min-height: 100dvh; background: #f1f5f9; }
.header {
  background: #0f172a;
  color: #fff;
  padding: 0.75rem 1rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-top: max(0.75rem, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.header h1 { margin: 0; font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; letter-spacing: -0.025em; }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 1rem; min-height: 44px; min-width: 44px; border-radius: 8px; font-size: 0.875rem; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: background 0.2s, opacity 0.2s; }
.btn { background: #0f172a; color: #fff; }
.btn:hover { background: #1e293b; }
.btn:active { opacity: 0.9; }
.btn-outline { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.4); }
.btn-outline:hover { background: rgba(255,255,255,0.08); text-decoration: none; border-color: rgba(255,255,255,0.6); }

.main { padding: 1rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: max(1rem, env(safe-area-inset-bottom)); max-width: 1400px; margin: 0 auto; }
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); padding: 1.25rem; margin-bottom: 1rem; border: 1px solid #e2e8f0; }
.card h2 { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; letter-spacing: -0.025em; color: #0f172a; }

/* Filters – modern UI */
.filters.card {
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
}
.filter-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
}
.filter-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.025em;
}
.filter-toggle {
  display: none;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  min-height: 40px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.filter-toggle:hover { color: #0ea5e9; border-color: #cbd5e1; background: #f8fafc; }
.filter-toggle-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  transition: transform 0.2s;
}
.filters.is-collapsed .filter-toggle-icon { transform: rotate(-90deg); }
.filter-panel { padding: 1.25rem; }
.filter-form { display: flex; flex-direction: column; gap: 1.25rem; }
.filter-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.filter-row { display: flex; flex-direction: column; min-width: 0; }
.filter-row label {
  font-size: 0.8125rem;
  margin-bottom: 0.375rem;
  font-weight: 600;
  color: #334155;
  letter-spacing: 0.01em;
}
.filter-row input {
  padding: 0.5rem 0.875rem;
  min-height: 44px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  width: 160px;
  max-width: 100%;
  font-size: 15px;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-row input::placeholder { color: #94a3b8; }
.filter-row input:hover { border-color: #cbd5e1; }
.filter-row input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.filter-row select {
  padding: 0.5rem 2.25rem 0.5rem 0.875rem;
  min-height: 44px;
  width: 180px;
  max-width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: #0f172a;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.1rem;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-row select:hover { border-color: #cbd5e1; }
.filter-row select:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
  border-top: 1px solid #e2e8f0;
}
.filter-actions .btn-apply { font-weight: 600; min-height: 44px; padding: 0.5rem 1.25rem; border-radius: 8px; }
.btn-clear-filters {
  min-height: 44px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-clear-filters:hover { background: #e2e8f0; color: #0f172a; border-color: #cbd5e1; text-decoration: none; }

.btn-filters { position: relative; }
.filter-badge {
  display: inline-block;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  color: #fff;
  background: #0d9488;
  border-radius: 999px;
  vertical-align: middle;
}
/* Filters page (separate page) */
.filters-page .main-filters { max-width: 520px; margin: 0 auto; }
.filters-page .filters-card { padding: 1.5rem; }
.filters-page .filter-form-page .filter-fields-page {
  flex-direction: column;
  gap: 1.25rem;
  align-items: stretch;
}
.filters-page .filter-form-page .filter-row input,
.filters-page .filter-form-page .filter-row select { width: 100%; max-width: none; }
.filters-page .filter-actions-page {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.filters-page .filter-actions-page .btn { min-height: 44px; }

/* Form page (add/edit as separate page) */
.form-page .main-form { max-width: 900px; margin: 0 auto; }
.form-page .form-card {
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}
.form-section-title { font-weight: 700; color: #334155; }
.form-current-photo { margin-top: 0.5rem; }
.form-current-photo .thumb { width: 64px; height: 64px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

/* Add form (modal) – modern form styling */
.form-sections { display: flex; flex-direction: column; gap: 0; }
.form-section { margin-bottom: 1.5rem; }
.form-section:last-of-type { margin-bottom: 0; }
.form-section-title {
  margin: 0 0 0.75rem; padding-bottom: 0.5rem; font-size: 0.8125rem; font-weight: 700;
  color: #475569; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid #e2e8f0;
}
.form-section:first-child .form-section-title { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field-row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.field label { font-size: 0.8125rem; margin-bottom: 0.375rem; font-weight: 600; color: #334155; letter-spacing: 0.01em; }
.req { color: #b91c1c; }

/* Modern text inputs & textarea */
.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field textarea {
  padding: 0.625rem 0.875rem;
  min-height: 44px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field input::placeholder,
.field textarea::placeholder { color: #94a3b8; }
.field input:hover,
.field textarea:hover { border-color: #cbd5e1; }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.field textarea { min-height: auto; resize: vertical; min-height: 72px; }

/* Enhanced select dropdowns */
.field select {
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  min-height: 44px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: #0f172a;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field select:hover { border-color: #cbd5e1; }
.field select:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.field select option {
  padding: 0.5rem 0.75rem;
  font-weight: 500;
  background: #fff;
}

/* File input – modern look */
.field input[type="file"] {
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  font-size: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
}
.field input[type="file"]:hover { border-color: #94a3b8; background: #f1f5f9; }
.field input[type="file"]:focus { outline: none; border-color: #0ea5e9; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }

.field input:invalid:not(:placeholder-shown), .field.invalid input, .field.invalid textarea, .field.invalid select { border-color: #b91c1c; }
.field.invalid select { box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.15); }
.field-error { font-size: 0.8rem; color: #b91c1c; margin-top: 0.25rem; }
.form-actions { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid #e2e8f0; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.form-actions .btn {
  min-height: 44px; padding: 0.625rem 1.25rem; font-weight: 600; border-radius: 8px;
  background: #0f172a; color: #fff;
  transition: background 0.2s, opacity 0.2s;
}
.form-actions .btn:hover { background: #1e293b; }
.form-actions .btn-outline { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; box-shadow: none; }
.form-actions .btn-outline:hover { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }

/* Table section */
.table-section-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.table-section-header-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; min-width: 0; flex: 1; }
.table-section-header h2 { margin: 0; font-size: 1rem; }
.table-section-header .btn { flex-shrink: 0; }
.table-section-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.btn-export-excel { background: #0ea5e9; color: #fff; }
.btn-export-excel:hover { background: #0284c7; text-decoration: none; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.dashboard-search-form { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.dashboard-search-form .dashboard-search-input {
  flex: 1; min-width: 200px; max-width: 320px;
  padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.9375rem;
  min-height: 44px; background: #f8fafc; color: #0f172a;
}
.dashboard-search-form .dashboard-search-input:focus {
  outline: none; border-color: #0ea5e9; box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2); background: #fff;
}
.dashboard-search-form .btn-search { flex-shrink: 0; }

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; overflow-y: visible; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 600px; }
.data-table th, .data-table td { padding: 0.5rem 0.5rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.data-table th { background: #f1f5f9; font-weight: 600; white-space: nowrap; }
.data-table thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 0 #e2e8f0; }
.data-table th:first-child, .data-table td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; }
.data-table thead th:first-child { z-index: 3; background: #f1f5f9; }
.data-table tbody td:first-child { background: #fff; }
.data-table tbody tr:hover td:first-child { background: #f8fafc; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .empty { text-align: center; color: #64748b; padding: 1.5rem; }

/* Table footer */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem 0 0;
  border-top: 1px solid #e2e8f0;
}
.table-footer-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.table-footer-summary {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
}
.table-footer-per-page {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.table-footer-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
}
.table-footer-right {
  display: flex;
  align-items: center;
}
.per-page-select,
.sort-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem; min-height: 40px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 0.9rem; font-weight: 500; color: #0f172a; background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 1rem;
  appearance: none; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
}
.per-page-select { min-width: 4.5rem; }
.sort-select { min-width: 11rem; }
.per-page-select:focus, .sort-select:focus { outline: none; border-color: #0ea5e9; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }
.sort-by { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.sort-by-label { font-size: 0.9rem; color: #64748b; margin-right: 0.25rem; }
.pagination { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.pagination-info { font-size: 0.875rem; font-weight: 500; color: #64748b; }
.pagination-links { display: flex; gap: 0.375rem; flex-wrap: wrap; align-items: center; }
.btn-outline-pagination {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.btn-outline-pagination:hover { background: #f8fafc; border-color: #cbd5e1; text-decoration: none; }
.pagination-current {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Table actions cell */
.actions-cell { white-space: nowrap; }
.actions-cell .btn-edit { margin-right: 0.25rem; }
.actions-cell .btn-edit,
.actions-cell .btn-delete { min-height: 36px; min-width: 44px; padding: 0.4rem 0.6rem; }
.delete-form-inline { display: inline; }
.delete-form-inline button { margin: 0; }
.btn-delete { background: #b91c1c; color: #fff; }
.btn-delete:hover { background: #991b1b; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.btn-sm { padding: 0.4rem 0.65rem; min-height: 36px; min-width: 44px; font-size: 0.8rem; }
.btn-edit { background: #0ea5e9; color: #fff; }
.btn-edit:hover { background: #0284c7; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; padding: 0.75rem; padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
.modal.is-open { display: flex; }
.modal-overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); cursor: pointer; backdrop-filter: blur(2px); }
.modal-box { position: relative; background: #fff; border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05); max-width: 900px; width: 100%; max-height: 90vh; max-height: 90dvh; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid #e2e8f0; background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); border-radius: 16px 16px 0 0; }
.modal .modal-header h2 { margin: 0; font-size: 1.0625rem; font-weight: 600; color: #0f172a; letter-spacing: -0.025em; }
.modal-close { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 1.25rem; line-height: 1; cursor: pointer; color: #64748b; padding: 0.5rem; min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; transition: color 0.2s, border-color 0.2s, background 0.2s; }
.modal-close:hover { color: #0f172a; border-color: #cbd5e1; background: #f8fafc; }
.modal form { padding: 1.5rem; background: #fff; }
.modal .form-actions { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid #e2e8f0; }
.field-hint { font-size: 0.8rem; color: #64748b; margin-top: 0.25rem; }

/* PWA: Offline banner */
.pwa-offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 2500; padding: 0.6rem 1rem; background: #b91c1c; color: #fff; text-align: center; font-size: 0.9rem; font-weight: 500; display: none; box-shadow: 0 2px 8px rgba(0,0,0,0.2); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-top: max(0.6rem, env(safe-area-inset-top)); }
.pwa-offline-banner.is-visible { display: block; }
body.offline-banner-visible { padding-top: 2.75rem; }

/* Existing record dialog (form page) */
.existing-record-dialog { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 1rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
.existing-record-dialog.is-visible { display: flex; }
.existing-record-dialog-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); cursor: pointer; }
.existing-record-dialog-box { position: relative; background: #fff; border-radius: 16px; box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 20px 50px rgba(0,0,0,0.2); padding: 1.5rem; max-width: 360px; width: 100%; border: 1px solid rgba(0,0,0,0.06); }
.existing-record-dialog-box h2 { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 600; color: #0f172a; letter-spacing: -0.025em; }
.existing-record-dialog-box p { margin: 0 0 1rem; color: #475569; font-size: 0.9375rem; line-height: 1.5; }
.existing-record-dialog-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* PWA: Update available dialog */
.pwa-dialog { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 1rem; }
.pwa-dialog.is-visible { display: flex; }
.pwa-dialog-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); }
.pwa-dialog-box {
  position: relative; background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 20px 50px rgba(0,0,0,0.2);
  padding: 1.5rem; max-width: 360px; width: 100%;
  border: 1px solid rgba(0,0,0,0.06);
}
.pwa-dialog-box h2 { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 600; color: #0f172a; letter-spacing: -0.025em; }
.pwa-dialog-box p { margin: 0 0 1rem; color: #475569; font-size: 0.9375rem; line-height: 1.5; }
.pwa-dialog-actions { display: flex; gap: 0.75rem; }
.btn-outline-pwa { background: #fff; color: #0f172a; border: 1px solid #cbd5e1; font-weight: 600; border-radius: 8px; }
.btn-outline-pwa:hover { background: #f1f5f9; border-color: #94a3b8; }

/* PWA: Add to home screen banner – LLM Lens style */
.pwa-add-home {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1500;
  padding: max(0.75rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
  display: none;
}
.pwa-add-home.is-visible { display: block; }
.pwa-add-home-inner {
  max-width: 420px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem;
  background: #0f172a;
  color: #fff;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  border: 1px solid #e2e8f0;
  border-bottom: none;
}
.pwa-add-home-inner p { margin: 0 0 0.75rem; font-size: 0.9rem; font-weight: 500; line-height: 1.4; }
.pwa-add-home-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.pwa-add-home-actions .btn {
  background: #fff;
  color: #0f172a;
  border: none;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.2s, opacity 0.2s;
}
.pwa-add-home-actions .btn:hover { background: #f1f5f9; }
.pwa-add-home-actions .btn-outline-pwa { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.4); }
.pwa-add-home-actions .btn-outline-pwa:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.6); }
.pwa-add-home-ios { font-size: 0.8rem; opacity: 0.9; margin: 0.5rem 0 0; }

/* Mobile responsive */
@media (max-width: 768px) {
  .main { padding: 0.75rem; padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
  .card { padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
  /* Header: wrap so h1 goes to second row, brand + action on first */
  .header { gap: 0.5rem; }
  .header .app-brand { flex-shrink: 0; }
  .header h1 { flex: 1 1 100%; order: 3; margin-top: 0.25rem; font-size: 0.95rem; }
  .header .btn, .header a.btn { flex-shrink: 0; min-height: 44px; min-width: 44px; }
  /* Filter: show toggle, collapsible panel, stacked fields */
  .filter-toggle { display: inline-flex; }
  .filters.card .filter-panel {
    padding: 0 1.25rem 1.25rem;
    transition: opacity 0.2s ease, max-height 0.3s ease;
  }
  .filters.is-collapsed .filter-panel {
    display: none;
  }
  .filters.card .filter-card-header { padding: 0.875rem 1rem; }
  .filter-fields {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  .filter-row { min-width: 0; }
  .filter-row input,
  .filter-row select { width: 100%; min-width: 0; max-width: none; }
  .filter-form { gap: 1rem; }
  .filter-actions {
    flex-direction: row;
    gap: 0.75rem;
    padding-top: 0.5rem;
  }
  .filter-actions .btn,
  .filter-actions .btn-clear-filters { flex: 1; min-width: 0; min-height: 44px; }
  .table-section-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .table-section-header-left { flex: none; }
  .table-section-header-actions { width: 100%; gap: 0.5rem; }
  .table-section-header-actions .btn,
  .table-section-header-actions a.btn { flex: 1; min-width: 120px; min-height: 44px; }
  .table-footer { flex-direction: column; align-items: stretch; gap: 0.75rem; padding-top: 0.75rem; }
  .table-footer-left { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .table-footer-right { width: 100%; justify-content: center; }
  .per-page, .sort-by { flex-wrap: wrap; }
  .per-page-select, .sort-select { flex: 1; min-width: 0; max-width: 100%; min-height: 44px; }
  .pagination { flex-direction: row; align-items: center; justify-content: center; flex-wrap: wrap; }
  .pagination-links { justify-content: center; }
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 0.4rem 0.35rem; }
  .thumb { width: 32px; height: 32px; }
  .modal-box { max-height: 85vh; max-height: 85dvh; border-radius: 12px; }
  .modal form { padding: 0.75rem; }
  .form-page .form-card { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .field-row { grid-template-columns: 1fr; gap: 0.75rem; }
  .form-actions { flex-direction: column; gap: 0.5rem; }
  .form-actions .btn { width: 100%; min-height: 44px; }
  .pwa-dialog-box { margin: 0.5rem; padding: 1.25rem; }
  .pwa-dialog-actions { flex-direction: column; }
  .pwa-dialog-actions .btn { width: 100%; min-height: 44px; }
  .pwa-add-home { padding: 0.75rem max(1rem, env(safe-area-inset-left)); padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
  .pwa-add-home-actions { flex-direction: column; }
  .pwa-add-home-actions .btn { width: 100%; min-height: 44px; }
}

@media (max-width: 480px) {
  .header { padding: 0.6rem 0.75rem; padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
  .header h1 { font-size: 0.9rem; }
  .app-brand-logo { width: 36px; height: 36px; }
  .app-brand-name { font-size: 0.9rem; }
  .app-brand-top .app-brand-logo { width: 48px; height: 48px; }
  .app-brand-top .app-brand-name { font-size: 1.15rem; }
  .login-page .login-box { margin: 0.5rem auto; }
  .login-box { padding: 1.25rem 1rem; }
  .login-box h1 { font-size: 1.25rem; }
  .card h2 { font-size: 1rem; }
  .table-section-header h2 { font-size: 0.95rem; }
  .btn-sm { padding: 0.35rem 0.5rem; font-size: 0.75rem; min-height: 44px; }
  .actions-cell .btn-edit, .actions-cell .btn-delete { min-height: 44px; min-width: 44px; padding: 0.5rem 0.75rem; }
  .form-section-title { font-size: 0.75rem; }
  .thank-you-card { padding: 1.25rem; margin: 0 0.75rem; }
  .thank-you-message { font-size: 1rem; }
  .thank-you-card .btn { width: 100%; max-width: 280px; min-height: 44px; }
}

/* Very small phones */
@media (max-width: 360px) {
  .header h1 { font-size: 0.85rem; }
  .app-brand-name { font-size: 0.85rem; }
  .app-brand-top .app-brand-name { font-size: 1rem; }
  .login-box { padding: 1rem 0.75rem; }
  .table-section-header-actions .btn,
  .table-section-header-actions a.btn { min-width: 0; flex: 1 1 auto; font-size: 0.8rem; padding: 0.5rem 0.5rem; }
}

/* Thank-you page (public form) */
.thank-you-page .main { padding-top: 2rem; }
.thank-you-card {
  text-align: center;
  max-width: 420px;
  margin-left: auto; margin-right: auto;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 12px 28px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.04);
}
.thank-you-message { font-size: 1.1rem; line-height: 1.6; margin: 0 0 1.5rem; color: #334155; font-weight: 500; }
.thank-you-card .btn {
  min-width: 200px; min-height: 44px;
  background: #0f172a; color: #fff;
  border-radius: 8px; font-weight: 600;
  transition: background 0.2s, opacity 0.2s;
}
.thank-you-card .btn:hover { background: #1e293b; }
