* { box-sizing: border-box; }

:root {
  --brand-dark: #1e3a5f;
  --brand: #2c5282;
  --brand-light: #ebf2fa;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --border-soft: #e5e7eb;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --success: #065f46;
  --success-bg: #f0fdf4;
  --warn: #92400e;
  --warn-bg: #fffbeb;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

header.app-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: white;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
header.app-header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
header.app-header .sub { font-size: 0.78rem; opacity: 0.85; margin-top: 0.2rem; }
header.app-header .user-chip {
  font-size: 0.8rem;
  opacity: 0.92;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
header.app-header .logout-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
header.app-header .logout-btn:hover { background: rgba(255,255,255,0.22); }

main {
  max-width: 720px;
  margin: 1.5rem auto;
  padding: 0 1rem 4rem;
}

/* Auth pages — centered narrow card */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: linear-gradient(160deg, var(--brand-dark) 0%, var(--brand) 60%, #4a6b95 100%);
}
.auth-brand {
  text-align: center;
  margin-bottom: 1rem;
}
.auth-logo-wrap {
  background: white;
  border-radius: 10px;
  padding: 4px 6px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.auth-logo {
  display: block;
  height: 72px;
  width: auto;
  max-width: 240px;
}
.auth-card {
  background: var(--card);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.75rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}
.auth-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.auth-card .auth-desc {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  text-align: center;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-weight: 600;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin: 0.85rem 0 0.3rem;
}
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: white;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.btn-secondary {
  background: white;
  color: var(--brand);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f9fafb; border-color: var(--brand); }

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.85rem;
}
.auth-links a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}
.auth-links a:hover { text-decoration: underline; }

.alert {
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #fecaca;
}
.alert.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #bbf7d0;
}
.alert.show { display: block; }

.help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 1.25rem 0;
}

/* Dashboard tiles */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.tile {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tile:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(44, 82, 130, 0.12);
  transform: translateY(-1px);
}
.tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}
.tile-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.tile-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr; }
}

.tile.placeholder {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
  background: #f9fafb;
}
.tile.placeholder .tile-icon {
  background: #e5e7eb;
  color: #6b7280;
}
.tile.placeholder .tile-sub {
  color: #b45309;
  font-weight: 500;
}

.sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: #92400e;
}
.sync-banner .sync-text { flex: 1; }
.sync-banner .sync-btn {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.sync-banner .sync-btn:hover { background: #d97706; }
.sync-banner .sync-btn:disabled { background: #9ca3af; cursor: not-allowed; }

/* Install ("Download App") button */
.install-app-btn {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  background: #00c875;
  color: white;
  border: none;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: none;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, transform 0.05s;
}
.install-app-btn.show { display: inline-flex; }
.install-app-btn:hover { background: #00a85a; }
.install-app-btn:active { transform: translateY(1px); }
.install-app-btn .install-icon {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
@media (max-width: 480px) {
  .install-app-btn {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
  }
}

/* Install modal */
.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.install-modal[hidden] { display: none; }
.install-modal-card {
  background: white;
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}
.install-modal-card h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: var(--text);
  text-align: center;
}
.install-modal-card p { margin: 0 0 0.85rem; font-size: 0.9rem; color: #374151; }
.install-modal-card ol, .install-modal-card ul {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.6;
}
.install-modal-card .install-modal-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}
.install-modal-card .install-modal-close { margin-top: 0.5rem; }
