@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --primary: #5aa9e6;
  --primary-dark: #2f8fd4;
  --bg: #eef6ff;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.84);
  --border: rgba(90, 169, 230, 0.28);
  --text: #123448;
  --text-muted: #5e7d93;
  --danger: #d64949;
  --success: #2f9e44;
  --warning: #d98324;
  --sidebar: #102536;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow: 0 8px 24px rgba(26, 77, 116, 0.12);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 15% -10%, #d9ecff 0%, transparent 42%),
    radial-gradient(circle at 85% -20%, #cfe9ff 0%, transparent 46%),
    var(--bg);
}

a {
  color: var(--primary-dark);
}

#appShell {
  display: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 14px;
  padding: 12px;
}

.sidebar {
  background: var(--sidebar);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 30px rgba(2, 16, 28, 0.32);
}

.sidebar-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding-bottom: 14px;
}

.brand-title {
  letter-spacing: 0.1em;
  font-weight: 800;
  font-size: 0.92rem;
  color: #e6f4ff;
}

.brand-subtitle {
  margin-top: 4px;
  font-size: 0.78rem;
  color: rgba(230, 244, 255, 0.62);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  border: 0;
  border-radius: 10px;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-item:hover {
  background: rgba(90, 169, 230, 0.2);
  color: #fff;
  transform: translateX(3px);
}

.nav-item.is-active {
  background: var(--primary);
  color: #fff;
}

.main-wrapper {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.topbar {
  background: linear-gradient(120deg, #56a6e3, #76bbea);
  padding: 16px 20px;
  color: #fff;
}

.page-title {
  font-size: 1.2rem;
}

.page-subtitle {
  margin-top: 2px;
  font-size: 0.84rem;
  opacity: 0.92;
}

.page-body {
  padding: 18px;
  overflow: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card h2 {
  font-size: 1.02rem;
  margin-bottom: 6px;
}

.card-grid {
  display: grid;
  gap: 14px;
}

.card-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-stack {
  display: grid;
  gap: 10px;
}

.form-stack label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input {
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: #fff;
  padding: 9px 10px;
}

.input:focus {
  outline: 2px solid rgba(90, 169, 230, 0.25);
  border-color: var(--primary);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 150ms ease;
}

.btn:hover {
  filter: brightness(0.96);
}

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

.btn--primary {
  background: var(--primary);
  color: #fff;
}

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

.btn--table {
  padding: 6px 9px;
  font-size: 0.78rem;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.88);
}

.btn--ghost-light {
  background: #f3f7fc;
  border-color: rgba(90, 169, 230, 0.35);
  color: var(--text);
}

.btn--full {
  width: 100%;
}

.camera-preview {
  width: 100%;
  border-radius: 10px;
  margin-top: 8px;
  min-height: 220px;
  background: #1f2f3d;
  object-fit: cover;
}

.time-now {
  margin-top: 8px;
  border-radius: 10px;
  background: #eaf4ff;
  border: 1px solid rgba(90, 169, 230, 0.3);
  padding: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 37, 54, 0.58);
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 12px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(620px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(90, 169, 230, 0.3);
  box-shadow: 0 16px 30px rgba(8, 25, 38, 0.3);
  padding: 16px;
}

.overwrite-confirm {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #f0c16b;
  background: #fff7e8;
  border-radius: 10px;
}

.overwrite-confirm__label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #8a5813;
  font-size: 0.84rem;
  font-weight: 600;
}

.captured-image {
  display: none;
  width: 100%;
  border-radius: 10px;
  margin-top: 8px;
}

.captured-image--visible {
  display: block;
}

.status-box {
  background: #eff7ff;
  border: 1px solid #c9e4fb;
  border-radius: 10px;
  padding: 10px;
  margin-top: 8px;
  font-size: 0.88rem;
}

.section-gap {
  margin-top: 16px;
}

.muted {
  color: var(--text-muted);
  font-size: 0.86rem;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid rgba(90, 169, 230, 0.18);
  vertical-align: top;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 700;
}

.status-pill {
  display: inline-block;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
}

.status-pill--pending,
.status-pill--open {
  background: #ffeac8;
  color: #9a5f13;
}

.status-pill--approved,
.status-pill--resolved {
  background: #dbf5e2;
  color: #1e7e36;
}

.status-pill--rejected,
.status-pill--declined {
  background: #ffd8d8;
  color: #a82626;
}

.status-pill--cancelled {
  background: #f0f1f4;
  color: #5b6070;
}

.info-card {
  border: 1px solid rgba(90, 169, 230, 0.25);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
}

.info-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.info-kv {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.84rem;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kv-item {
  border: 1px solid rgba(90, 169, 230, 0.2);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.kv-key {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.kv-value {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Login and splash screens */
.login-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.login-card {
  width: min(380px, 100%);
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
}

.login-title {
  font-size: 1.3rem;
}

.login-subtitle {
  margin-top: 8px;
  color: var(--text-muted);
}

.login-notice,
.login-footer {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.dev-login-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(90, 169, 230, 0.2);
  text-align: left;
}

.login-spinner {
  width: 34px;
  height: 34px;
  margin: 14px auto;
  border: 3px solid rgba(90, 169, 230, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #eef6ff;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#splash.splash--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#splash-wordmark {
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
}

#splash-bar {
  width: 120px;
  height: 4px;
  border-radius: 99px;
  background: rgba(90, 169, 230, 0.2);
  overflow: hidden;
}

#splash-bar::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  animation: splash-slide 1.1s ease-in-out infinite;
}

#toast-container {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #243441;
  color: #fff;
  font-size: 0.84rem;
  border-radius: 8px;
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  box-shadow: 0 8px 20px rgba(6, 18, 27, 0.28);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
.toast--warning { background: var(--warning); color: #291708; }

.dtr-groups {
  display: grid;
  gap: 12px;
}

.dtr-group-card {
  background: #fff;
}

.dtr-group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.dtr-group-head h3 {
  font-size: 1rem;
  margin-bottom: 2px;
}

.dtr-metrics {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.dtr-adjust-input {
  margin-top: 4px;
  width: 220px;
}

.dtr-day-total-input {
  width: 110px;
  padding: 6px 8px;
}

.table-wrap {
  overflow-x: auto;
}

.dtr-proof-modal-card {
  width: min(900px, 100%);
  max-height: 88vh;
  overflow: auto;
}

.dtr-proof-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dtr-proof-image {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(90, 169, 230, 0.3);
}

@keyframes splash-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 12px;
    gap: 10px;
  }

  .nav-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid--2,
  .card-grid--3,
  .kv-grid,
  .dtr-proof-grid {
    grid-template-columns: 1fr;
  }
}
