/* AQUAffection Admin — Sales Tracker design language */
:root {
  --navy1: #142F5C;
  --navy2: #1b3e78;
  --cyan: #1CA3D6;
  --cyan-dark: #158ab8;
  --canvas: #eef2f7;
  --card: #ffffff;
  --ink: #16233b;
  --muted: #64748b;
  --line: #dbe3ee;
  --ok: #1a9e63;
  --warn: #d97706;
  --bad: #d64545;
  --shadow: 0 2px 10px rgba(20, 47, 92, .10);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--canvas); color: var(--ink); }
h1, h2, h3 { line-height: 1.2; }
a { color: var(--cyan-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(100deg, var(--navy1), var(--navy2));
  color: #fff; padding: 10px 18px; position: sticky; top: 0; z-index: 50;
}
.header-logo { height: 36px; }
.header-sep { width: 1px; height: 26px; background: rgba(255,255,255,.35); }
.header-title { font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.header-spacer { flex: 1; }
.header-user { font-size: 13px; opacity: .85; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 2px 6px; }

/* ---------- layout ---------- */
.app-body { display: flex; min-height: calc(100vh - 54px); }
.sidebar {
  width: 216px; flex: 0 0 216px; background: #fff; border-right: 1px solid var(--line);
  padding: 14px 10px; position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto;
}
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 16px 8px 6px; }
.nav-group:first-child { margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink); font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-size: 14.5px;
}
.nav-item:hover { background: #f1f6fb; text-decoration: none; }
.nav-item.active { background: #e2f3fb; color: #0d6d95; }
.nav-item .ico { width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.main { flex: 1; padding: 22px 26px 60px; min-width: 0; }

/* ---------- cards / page ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .spacer { flex: 1; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--navy1); }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* KPI tiles */
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; }
.kpi .n { font-size: 26px; font-weight: 700; color: var(--navy1); }
.kpi .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.accent .n { color: var(--cyan-dark); }
.kpi.bad .n { color: var(--bad); }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 9px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; background: #e8edf4; color: var(--ink);
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--cyan); color: #fff; box-shadow: 0 2px 6px rgba(28,163,214,.35); }
.btn-primary:hover { background: var(--cyan-dark); filter: none; }
.btn-danger { background: #fbe9e9; color: var(--bad); }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: default; }

label.f { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #33415c; }
label.f > input, label.f > select, label.f > textarea, .login-card label > input {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font-size: 14.5px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-family: inherit;
}
label.f > textarea { min-height: 84px; resize: vertical; }
label.f > input:focus, label.f > select:focus, label.f > textarea:focus, .login-card input:focus {
  outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.form-error { background: #fbe9e9; color: var(--bad); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px; }
.hint { font-size: 12.5px; color: var(--muted); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #edf1f7; vertical-align: top; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover { background: #f4f8fc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-issued { background: #ede9fe; color: #6d28d9; }
.b-assigned { background: #e0f2fe; color: #0369a1; }
.b-inprogress { background: #fef3c7; color: #b45309; }
.b-completed { background: #d9f2e5; color: #157347; }
.b-deleted { background: #f1f5f9; color: #64748b; }
.b-ok { background: #d9f2e5; color: #157347; }
.b-warn { background: #fef3c7; color: #b45309; }
.b-bad { background: #fbe9e9; color: #c03535; }
.b-muted { background: #eef2f7; color: #5a6b85; }

/* ---------- search bar ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
}
.toolbar input[type=search] { min-width: 220px; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--cyan); border-color: var(--cyan); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(120deg, var(--navy1), var(--navy2)); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 34px 34px 28px; width: 100%; max-width: 400px; text-align: center; }
.login-logo { height: 54px; margin-bottom: 8px; }
.login-card h1 { margin: 0; font-size: 24px; color: var(--navy1); }
.login-sub { color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
.login-card form { text-align: left; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: #33415c; }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,26,47,.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; }
.modal { background: #fff; border-radius: 14px; box-shadow: 0 16px 60px rgba(0,0,0,.3); width: 100%; max-width: 640px; padding: 22px 24px; max-height: calc(100vh - 80px); overflow-y: auto; overscroll-behavior: contain; }
.modal.wide { max-width: 900px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; color: var(--navy1); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy1); color: #fff; padding: 11px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 200; font-size: 14px; animation: toastin .2s ease-out; }
.toast.err { background: var(--bad); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- detail pages ---------- */
.dl { display: grid; grid-template-columns: 190px 1fr; gap: 6px 14px; font-size: 14px; }
.dl dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.dl dd { margin: 0; min-width: 0; word-wrap: break-word; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.sig-pad { border: 1.5px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 160px; }

/* leave calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; }
.cal .day { min-height: 74px; background: #fff; border: 1px solid #e8edf4; border-radius: 8px; padding: 4px 6px; font-size: 12px; }
.cal .day.dim { opacity: .4; }
.cal .day .d { font-weight: 600; color: var(--muted); font-size: 11px; }
.cal .ev { margin-top: 3px; border-radius: 5px; padding: 1px 5px; font-size: 11px; background: #e0f2fe; color: #0a5c80; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev.sick { background: #fbe9e9; color: #b23131; }

/* timeline */
.tline { border-left: 2px solid var(--line); margin-left: 8px; padding-left: 18px; }
.tline .ev { position: relative; margin-bottom: 12px; }
.tline .ev::before { content: ''; position: absolute; left: -24px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); }
.tline .t { font-size: 12px; color: var(--muted); }

/* ---------- print (jobcard PDF) ---------- */
@media print {
  .app-header, .sidebar, .toolbar, .noprint, #toast-root, #modal-root { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .sidebar { position: fixed; left: 0; top: 54px; bottom: 0; z-index: 60; transform: translateX(-105%); transition: transform .18s ease; box-shadow: 4px 0 18px rgba(0,0,0,.15); height: auto; }
  .sidebar.open { transform: none; }
  .main { padding: 14px 12px 60px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dt { margin-top: 8px; }
  .header-user { display: none; }
}
