/* Inspire CRM v1.1 — Top-nav layout */
* { box-sizing: border-box; }
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7793;
  --line: #e5e9f2;
  --primary: #1d4ed8;
  --primary-2: #1e3a8a;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
  --info: #0ea5e9;
  --mute: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.08);
}
html, body { margin:0; padding:0; height:100%; }
body { font-family: 'Segoe UI', Roboto, system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size:14px; line-height:1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin:0 0 8px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.wrap { max-width: 280px; white-space: normal; }

/* ============ TOP NAV ============ */
.topnav {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.topnav-inner {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  max-width: 100%;
}
.brand { display:flex; gap:10px; align-items:center; text-decoration:none; color:#fff; flex-shrink: 0; }
.brand:hover { text-decoration:none; }
.brand .logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #1d4ed8, #6366f1);
  border-radius: 8px;
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight: 700; font-size: 15px;
}
.brand .logo.lg { width: 56px; height:56px; font-size: 22px; }
.brand-text { display:flex; flex-direction:column; line-height: 1.2; }
.brand-text strong { color:#fff; font-size: 15px; }
.brand-text .small { color: #94a3b8; }

.topnav-menu {
  display:flex; gap: 2px; flex: 1; flex-wrap: wrap;
  align-items: center;
}
.nav-item, .drop-toggle {
  display: inline-flex; align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  color: #cbd5e1;
  font-size: 13px; font-weight: 500;
  background: transparent; border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.nav-item:hover, .drop-toggle:hover { background: #334155; color: #fff; text-decoration: none; }

/* Dropdown */
.nav-drop { position: relative; }
.drop-menu {
  display: none;
  position: absolute; top: 100%; left: 0;
  background: #fff; color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  min-width: 200px;
  padding: 6px;
  z-index: 200;
  margin-top: 4px;
}
.drop-menu a {
  display: block;
  padding: 9px 14px;
  color: var(--ink);
  font-size: 13px;
  border-radius: 5px;
  text-decoration: none;
}
.drop-menu a:hover { background: #f1f5f9; color: var(--primary); }
.nav-drop:hover .drop-menu,
.nav-drop:focus-within .drop-menu { display: block; }

/* User chip */
.user-chip { display:flex; align-items:center; gap:10px; flex-shrink: 0; padding: 4px 8px; background: #1e293b; border-radius: 8px; }
.user-chip .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color:#fff; display:flex; align-items:center; justify-content:center; font-weight: 700; }
.user-meta { display:flex; flex-direction:column; line-height: 1.2; }
.user-meta strong { color: #fff; font-size: 13px; }
.user-meta .small { color: #94a3b8; }

/* ============ MAIN LAYOUT ============ */
.main {
  padding: 18px 22px 30px;
  max-width: 100%;
  min-height: calc(100vh - 130px);
}
.page-header {
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom: 16px;
  flex-wrap: wrap; gap: 10px;
}
.page-header h1 { font-size: 22px; margin: 0; }

.foot {
  padding: 12px 22px;
  display:flex; justify-content:space-between;
  font-size:12px; color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--panel);
}

/* Cards */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 18px; }
.card-h { display:flex; justify-content:space-between; align-items:center; gap:10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { font-size: 16px; }
.row { display:flex; gap:18px; flex-wrap:wrap; }
.row > .card { flex: 1; min-width: 280px; }
.flex-1 { flex: 1 1 280px; }
.flex-2 { flex: 2 1 480px; }

/* KPI */
.kpi-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap:12px; margin-bottom: 18px; }
.kpi-grid.sm .kpi { padding: 10px 12px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); display:flex; flex-direction:column; }
.kpi-ok { border-left-color: var(--ok); } .kpi-warn { border-left-color: var(--warn); } .kpi-info { border-left-color: var(--info); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 2px; }

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

/* Forms */
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=month], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; outline-offset: 1px; border-color: var(--primary); }
label { display:block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.check { display:flex; align-items:center; gap:6px; font-weight: 400; color: var(--ink); }
.check input { width:auto; }

.form-grid { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.one-col { grid-template-columns: 1fr; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
/* Cap form cards so they don't stretch edge-to-edge on wide monitors */
form.card { max-width: 1080px; }
@media (max-width: 1000px) { .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px)  { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; } }
.form-actions { grid-column: 1 / -1; display:flex; gap:8px; justify-content:flex-end; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; }
.sec { margin: 16px 0 4px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Buttons */
.btn { display:inline-flex; align-items:center; gap: 4px; padding: 7px 14px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); color:#fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); color:#fff; }
.btn-ok { background: var(--ok); color:#fff; border-color: var(--ok); } .btn-ok:hover { filter: brightness(0.95); color:#fff; }
.btn-warn { background: var(--warn); color:#fff; border-color: var(--warn); } .btn-warn:hover { filter: brightness(0.95); color:#fff; }
.btn-bad { background: var(--bad); color:#fff; border-color: var(--bad); } .btn-bad:hover { filter: brightness(0.95); color:#fff; }
.btn-mute { background: var(--mute); color:#fff; border-color: var(--mute); } .btn-mute:hover { filter: brightness(0.95); color:#fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: rgba(255,255,255,0.1); }
.user-chip .btn-ghost { color: #cbd5e1; }
.user-chip .btn-ghost:hover { color:#fff; background: #475569; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display:block; width: 100%; text-align:center; margin-top: 6px; }
.btn-row { display:flex; gap: 8px; }

/* Badges */
.badge { display:inline-block; padding: 3px 10px; font-size: 11px; font-weight: 600; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.badge-ok   { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-bad  { background: #fee2e2; color: #991b1b; }
.badge-mute { background: #e2e8f0; color: #475569; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border-left: 4px solid; }
.alert-ok   { background: #f0fdf4; border-color: var(--ok);   color: #14532d; }
.alert-bad  { background: #fef2f2; border-color: var(--bad);  color: #7f1d1d; }
.alert-info { background: #f0f9ff; border-color: var(--info); color: #0c4a6e; }

/* Filters */
.filters { display:flex; flex-wrap:wrap; gap:8px; margin-bottom: 12px; padding: 10px; background: #f8fafc; border-radius: 6px; }
.filters input, .filters select { width: auto; min-width: 140px; }
.row-flex { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

/* KV display */
.kv-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 10px 18px; }
.kv-grid > div { display:flex; flex-direction:column; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv-grid .span-2 { grid-column: span 2; }
.kv-grid span.muted { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }

/* Quick list */
.quick-list .quick-row { display:flex; justify-content:space-between; align-items:center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.quick-list .quick-row:last-child { border-bottom: none; }

/* Login */
.login-body { display:flex; min-height: 100vh; align-items:center; justify-content:center; background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%); margin: 0; }
.login-card { background: #fff; border-radius: 14px; padding: 32px; width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-brand { text-align:center; margin-bottom: 18px; }
.login-brand .logo { margin: 0 auto 8px; }
.login-card label { margin-top: 10px; }

/* Pagination */
.pagination { display:flex; gap:4px; margin: 14px 0; flex-wrap:wrap; }
.pagination a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); }
.pagination a.active { background: var(--primary); color:#fff; border-color: var(--primary); }

/* Calendar */
.cal { display:grid; grid-template-columns: repeat(7,1fr); gap: 4px; margin-top: 10px; }
.cal-cell { background: #f8fafc; border-radius: 6px; padding: 10px 6px; text-align:center; position: relative; min-height: 56px; }
.cal-cell.empty { background: transparent; }
.cal-cell .cal-d { font-weight: 700; color: var(--ink); }
.cal-cell .cal-tag { position:absolute; top: 4px; right: 6px; font-size: 10px; padding: 1px 5px; border-radius: 999px; background: #fff; }
.cal-present  { background: #dcfce7; }
.cal-half_day { background: #fef3c7; }
.cal-leave    { background: #e2e8f0; }
.cal-week_off { background: #f1f5f9; color: var(--muted); }
.cal-holiday  { background: #dbeafe; }
.cal-weekend  { background: #f1f5f9; color: var(--muted); }
.legend { display:flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend .dot { display:inline-block; width: 10px; height:10px; border-radius: 50%; margin-right: 4px; }
.legend .dot.ok { background: var(--ok); } .legend .dot.warn { background: var(--warn); } .legend .dot.mute { background: var(--mute); } .legend .dot.info { background: var(--info); }

/* Segmented radio (attendance) */
.seg { display:flex; gap:4px; flex-wrap:wrap; }
.seg label { display:inline-flex; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--muted); margin: 0; }
.seg label input { display:none; }
.seg label.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.seg label.seg-ok.on  { background: var(--ok);  border-color: var(--ok); }
.seg label.seg-warn.on{ background: var(--warn);border-color: var(--warn); }
.seg label.seg-mute.on{ background: var(--mute);border-color: var(--mute); }
.seg label.seg-info.on{ background: var(--info);border-color: var(--info); }

/* Timeline */
.timeline { padding-left: 4px; }
.tl-item { display:flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink:0; }

/* Progress bar */
.bar { width: 80px; height: 6px; background: #e2e8f0; border-radius: 999px; display:inline-block; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--ok), var(--info)); }

/* Inline form */
.inline-form { display:flex; gap:4px; flex-wrap: wrap; align-items: center; }
.small-input { width: 140px; padding: 4px 6px; }

/* HP Dashboard summary highlights */
.hp-summary { width: 100%; font-size: 13px; table-layout: auto; }
.hp-summary th, .hp-summary td { white-space: nowrap; padding: 6px 10px; }
.hp-summary .hp-label {
  text-align: left;
  font-weight: 600;
  background: #f8fafc;
  max-width: 260px;
  width: 260px;
  white-space: normal;
  word-wrap: break-word;
  font-size: 12px;
  line-height: 1.3;
}
.hp-summary thead th { background: #4a90e2; color: #fff; font-weight: 600; }
.hp-summary thead th.hp-label { background: #1e293b; }
.hp-summary tbody tr:nth-child(odd) td:not(.hp-label) { background: #f8fafc; }
.hp-summary .highlight-amber { background: #fcd34d !important; font-weight: 700; }
.hp-summary .highlight-red   { background: #fca5a5 !important; font-weight: 700; }
.hp-summary .highlight-green { background: #86efac !important; font-weight: 700; }

/* Responsive — collapse top nav into a "More" trigger on small screens */
@media (max-width: 900px) {
  .topnav-inner { flex-wrap: wrap; padding: 8px 12px; gap: 10px; }
  .topnav-menu { width: 100%; order: 3; overflow-x: auto; }
  .user-chip .user-meta { display: none; }
  .main { padding: 14px; }
}

/* Version tag in the top-left brand area */
.ver-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  border-radius: 4px;
}
.foot strong { color: var(--ink); font-weight: 700; }

/* Clickable KPI tiles */
.kpi-link { text-decoration: none; transition: box-shadow .12s, transform .12s; cursor: pointer; }
.kpi-link:hover { text-decoration: none; box-shadow: 0 4px 12px rgba(15,23,42,.12); transform: translateY(-1px); }
.kpi-link .kpi-label::after { content: " \2192"; opacity: .4; font-size: 11px; }

/* ============ PWA / Mobile tweaks ============ */
@media (max-width: 760px) {
  .topnav-inner { padding: 8px 10px; gap: 8px; }
  .brand-text { display: none; }            /* keep just the logo on small screens */
  .topnav-menu { gap: 0; }
  .nav-item, .drop-toggle { padding: 8px 9px; font-size: 12px; }
  .drop-menu { min-width: 180px; }
  .user-meta { display: none; }              /* avatar only on phones */
  .main { padding: 10px 10px 60px; }
  .card { padding: 12px; }
  .card-h { flex-direction: column; align-items: flex-start; gap: 8px; }
  .card-h h3 { font-size: 15px; }
  .kpi-value { font-size: 18px; }
  .table th, .table td { padding: 6px 5px; font-size: 12px; }
  h1 { font-size: 18px; }
  .page-header p { display: none; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select { width: 100%; min-width: 0; }
}
/* Tap-friendly buttons on touch devices */
@media (pointer: coarse) {
  .btn { min-height: 36px; }
  .btn-sm { min-height: 32px; padding: 6px 12px; }
  input, select, textarea { font-size: 16px; }  /* prevent iOS zoom on focus */
}
/* When installed as PWA (standalone) - tighter top spacing, hide install button */
@media (display-mode: standalone) {
  #install-pwa-btn { display: none !important; }
  body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}
