/* Ambata Field Operations — design tokens built from the logo's two brand
   colours: blue #1b75ba and red #de2828, sampled straight from the mark. */
:root {
  --brand-blue: #1b75ba; --brand-red: #de2828;
  --bg: #f2f7fc; --surface: #ffffff; --surface-2: #e9f2fb; --surface-3: #d7e8f8;
  --border: #cbdff2; --text: #0e1f2e; --text-muted: #4a6478; --text-faint: #7c95ab;
  --accent: #1b75ba; --accent-strong: #12578e; --accent-soft: #e2f0fc; --accent-soft-text: #12578e;
  --success: #0ea86a; --success-soft: #d8f6e8; --warning: #e08700; --warning-soft: #fdeed2;
  --danger: #de2828; --danger-soft: #fce0e0; --info: #1b75ba; --info-soft: #e2f0fc;
  --violet: #7038e0; --violet-soft: #ebe1fd;
  --shadow: 0 1px 2px rgba(14,31,46,0.06), 0 4px 16px rgba(27,117,186,0.10);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #102337; --surface: #1a3149; --surface-2: #23405d; --surface-3: #2d4f70;
    --border: #34587a; --text: #f0f7fd; --text-muted: #b3cbe0; --text-faint: #8aa6bf;
    --accent: #5cb4f7; --accent-strong: #95d0fb; --accent-soft: #17415f; --accent-soft-text: #95d0fb;
    --success: #3ce3a1; --success-soft: #0b4433; --warning: #ffc44d; --warning-soft: #4a3810;
    --danger: #ff7b72; --danger-soft: #522020; --info: #5cb4f7; --info-soft: #17415f;
    --violet: #b89dfb; --violet-soft: #2e2450;
    --shadow: 0 1px 2px rgba(0,0,0,0.30), 0 4px 16px rgba(0,0,0,0.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14.5px; line-height: 1.5;
}
h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; }
a { color: var(--accent); }
button, input, select, textarea { font-size: 14px; color: var(--text); font-family: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--brand-red);
  display: flex; align-items: center; gap: 14px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { height: 34px; width: 34px; object-fit: contain; display: block; }
.brand-name { font-weight: 800; font-size: 15px; }
.topbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-muted); }

.navtabs { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; gap: 2px; padding: 0 14px; overflow-x: auto; }
.navtab { background: none; border: none; cursor: pointer; padding: 11px 14px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.navtab:hover { color: var(--text); }
.navtab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

main { flex: 1; padding: 20px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view-title { font-size: 19px; margin: 0 0 3px; }
.view-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.kpi-value { font-weight: 800; font-size: 26px; line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; font-weight: 600; font-size: 13.5px; padding: 9px 15px; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

label.field-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
input[type=text], input[type=password], input[type=tel], input[type=email], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.field { margin-bottom: 13px; }
.field-error, .errorlist { color: var(--danger); font-size: 11.5px; margin-top: 4px; font-weight: 600; list-style: none; padding: 0; }

.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: var(--surface-2); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(ellipse at top, var(--accent-soft), var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 22px; text-align: center; }
.login-mark { width: 132px; height: auto; display: block; }

/* The logo's blue and red are fixed brand colours, so on a dark background
   they sit on a white plate rather than being recoloured. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-mark { background: #fff; border-radius: 8px; padding: 2px; }
  :root:not([data-theme="light"]) .login-mark { background: #fff; border-radius: 18px; padding: 10px 16px; }
}

.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.messages li.success { background: var(--success-soft); color: var(--success); }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.messages li.info { background: var(--info-soft); color: var(--info); }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,18,14,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.modal-title { font-weight: 800; font-size: 16px; }
.modal-body { padding: 14px 18px 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.backlink { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 12.5px; font-weight: 600; text-decoration: none; margin-bottom: 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-row select, .filter-row input[type=text], .filter-row input[type=date] { width: auto; min-width: 150px; }
.search-input { flex: 1; min-width: 200px; }

[data-section] { display: none; }
[data-section].is-open { display: block; }

.checklist-row { font-size: 12.5px; padding: 3px 0; }
.checklist-row.ok { color: var(--success); }
.checklist-row.missing { color: var(--danger); }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kanban-col { flex: 0 0 240px; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 12.5px; font-weight: 700; }
.kanban-count { background: var(--surface-2); color: var(--text-muted); border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); text-decoration: none; display: block; color: inherit; }
.kanban-card:hover { border-color: var(--accent); }
.kanban-card-title { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.kanban-card-meta { font-size: 11.5px; color: var(--text-muted); }

.timeline-item { border-left: 2px solid var(--accent-soft); padding: 2px 0 14px 14px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-time { font-size: 11px; color: var(--text-faint); }
.timeline-title { font-weight: 700; font-size: 13px; margin: 2px 0; }
.timeline-notes { font-size: 12.5px; color: var(--text-muted); }
.timeline-actor { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.tabstrip { display: flex; gap: 6px; margin-bottom: 14px; }
.tabstrip a { padding: 6px 13px; border-radius: 99px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); text-decoration: none; }
.tabstrip a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
