/* === Theme matches Flutter app: dark navy + orange accent === */
:root {
  --navy-900: #0F172A;
  --navy-800: #1E293B;
  --navy-700: #334155;
  --navy-600: #475569;
  --orange: #F97316;
  --orange-hover: #EA580C;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --text: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --error: #DC2626;
  --success: #16A34A;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ───── Top bar ───── */
.top-bar {
  background: var(--navy-900);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 38px; height: 38px; }
.brand-title { font-weight: 700; font-size: 17px; line-height: 1; }
.brand-sub { font-size: 12px; color: #94A3B8; margin-top: 4px; }
.user-box { display: flex; align-items: center; gap: 16px; }
.user-info { text-align: right; line-height: 1.2; }
.user-email { display: block; font-size: 14px; }
.user-role { font-size: 11px; color: var(--orange); text-transform: uppercase; font-weight: 600; letter-spacing: .5px; }

/* ───── Buttons ───── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); }
.btn-primary:disabled { background: #94A3B8; cursor: not-allowed; }
.btn-secondary { background: var(--navy-800); color: #fff; }
.btn-secondary:hover { background: var(--navy-700); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.25); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }
.btn-link {
  background: none; border: none; color: var(--orange);
  cursor: pointer; padding: 4px 0; font-size: 13px; font-weight: 500; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }

/* ───── Login screen ───── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 60%, var(--navy-700) 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 14px;
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo { width: 64px; height: 64px; margin-bottom: 8px; }
.login-brand h1 { margin: 6px 0 4px; font-size: 22px; color: var(--navy-900); }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 14px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--navy-800); }
.field input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--orange); }
.login-actions-row { display: flex; justify-content: flex-end; }
.error-msg {
  background: #FEE2E2;
  color: var(--error);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.login-help {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.login-help p { margin: 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

/* ───── Dashboard ───── */
.dashboard { padding: 28px 0 60px; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.page-header h2 { margin: 0 0 6px; font-size: 24px; color: var(--navy-900); }
.page-header p { margin: 0 0 22px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--navy-900); }
.tab.active { color: var(--navy-900); border-bottom-color: var(--orange); }
.tab-count {
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}
.tab.active .tab-count { background: var(--orange); color: #fff; }

/* ───── Doc list ───── */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
}
.doc-card:hover { border-color: var(--orange); }
.doc-info { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; color: var(--navy-900); margin-bottom: 4px; }
.doc-meta { font-size: 12.5px; color: var(--text-muted); }
.doc-meta .badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: var(--border); margin-right: 6px; font-weight: 600; font-size: 11px;
}
.badge-completed { background: #DCFCE7; color: #166534; }
.badge-signed    { background: #DBEAFE; color: #1E40AF; }
.badge-accepted  { background: #FEF3C7; color: #92400E; }
.badge-other     { background: var(--border); color: var(--navy-700); }
.doc-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state, .loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── Technician dashboard ───── */
.search-row { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.search-input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--orange); }

.customers-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.customer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.customer-card:hover {
  border-color: var(--orange);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.customer-name { font-weight: 600; color: var(--navy-900); margin-bottom: 4px; }
.customer-meta { font-size: 12.5px; color: var(--text-muted); }
.customer-stats { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.stat-chip {
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--navy-700);
}
.stat-chip.no-access { background: #FEE2E2; color: var(--error); }
.stat-chip.has-access { background: #DCFCE7; color: #166534; }

/* ───── Modal ───── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,0.6); }
.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  margin: 20px;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
}
.modal-header h3 { margin: 0 0 4px; font-size: 18px; color: var(--navy-900); }
.modal-header p { margin: 0; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-section { margin-top: 22px; }
.modal-section h4 { margin: 0 0 10px; font-size: 15px; color: var(--navy-900); }

.upload-section {
  background: var(--bg);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}
.upload-section h4 { margin: 0 0 4px; font-size: 15px; color: var(--navy-900); }
.upload-section .small { margin: 0 0 10px; }
.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-row input[type="file"] {
  flex: 1;
  min-width: 160px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}
.upload-row input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.upload-progress {
  margin-top: 10px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.upload-bar { height: 100%; width: 0; background: var(--orange); transition: width .2s; }
.upload-status { margin-top: 6px; font-size: 13px; color: var(--text-muted); }
.customer-actions-row {
  display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap;
}

.doc-list.compact .doc-card { padding: 12px 14px; }

/* ───── Toast ───── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  background: var(--navy-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--orange);
  animation: slideIn .25s;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ───── Responsive ───── */
@media (max-width: 640px) {
  .top-bar { padding: 12px 16px; }
  .container { padding: 0 16px; }
  .login-card { padding: 28px 22px; }
  .doc-card { flex-direction: column; align-items: stretch; }
  .doc-actions { justify-content: flex-end; }
  .customers-list { grid-template-columns: 1fr; }
  .upload-row { flex-direction: column; align-items: stretch; }
  .upload-row > * { width: 100%; }
}
