:root {
  --navy: #0f2748;
  --navy-700: #16365f;
  --navy-600: #1f4576;
  --accent: #1aa37a;
  --accent-600: #168a68;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e1e6ec;
  --text: #1b2733;
  --muted: #66707c;
  --danger: #c0392b;
  --warn: #b8860b;
  --ok: #1aa37a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 39, 72, .08), 0 4px 16px rgba(15, 39, 72, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy);
  color: #fff;
  padding: 0 20px;
  height: 58px;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #2dd4a0);
  display: grid; place-items: center; font-size: 18px; color: #06281e; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: #9fb4d4; }
.proto-tag {
  margin-left: 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  background: rgba(255,255,255,.12); padding: 3px 7px; border-radius: 20px; color: #cfe0f7;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.role-switch { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #cfe0f7; }
.role-switch select {
  background: var(--navy-600); color: #fff; border: 1px solid var(--navy-700);
  padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: calc(100vh - 58px); }
.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 10px; flex-shrink: 0; overflow-y: auto;
}
.nav-group { margin-bottom: 18px; }
.nav-group h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
  margin: 0 0 6px 10px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; color: var(--text); font-size: 13.5px; font-family: var(--font);
}
.nav-item:hover { background: #eef2f7; }
.nav-item.active { background: var(--navy); color: #fff; font-weight: 500; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }

.content { flex: 1; padding: 26px 30px; overflow-y: auto; }

/* ---------- Headings / page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Cards / grid ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat .lbl { font-size: 12px; color: var(--muted); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #fafbfd; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-open { background: #fff3cd; color: #856404; }
.badge-confirmed { background: #d4edf7; color: #0c5a73; }
.badge-running { background: #d9f2e6; color: #0c6b4a; }
.badge-done { background: #e7e9ee; color: #525a66; }
.badge-incident { background: #fbe0dd; color: var(--danger); }
.badge-ok { background: #d9f2e6; color: #0c6b4a; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font); font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid transparent; transition: .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-700); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f4f6f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: var(--font); background: #fff; color: var(--text);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

/* ---------- Availability grid ---------- */
.avail-table td.cell { text-align: center; cursor: pointer; user-select: none; font-weight: 600; }
.cell.avail { background: #e2f6ed; color: #0c6b4a; }
.cell.unavail { background: #fbe7e5; color: var(--danger); }
.cell.unset { color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend span::before { content: "■ "; }

/* ---------- Signature ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,22,40,.55); z-index: 50; }
.modal-backdrop:not([hidden]) { display: grid; place-items: center; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 4px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.sigpad { border: 2px dashed var(--border); border-radius: 8px; background: #fcfcfd; touch-action: none; width: 100%; display: block; }
.sig-thumb { border: 1px solid var(--border); border-radius: 6px; max-height: 70px; background: #fff; }

.empty { text-align: center; color: var(--muted); padding: 30px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tag-incident { color: var(--danger); font-weight: 600; }
.notice { background: #eef4fb; border: 1px solid #d4e2f3; color: var(--navy-600); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.access-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
