@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #101a35;
  --navy-dark: #0a1226;
  --accent: #4f5eea;
  --accent-2: #7c6ff0;
  --accent-light: #eef0fe;
  --accent-gradient: linear-gradient(135deg, #4f5eea 0%, #7c6ff0 100%);
  --bg: #f5f6fb;
  --card: #ffffff;
  --border: #e7e9f3;
  --text: #12162b;
  --text-muted: #6b7086;
  --green: #0e9f6e;
  --green-bg: #e5f8f0;
  --red: #d8352a;
  --red-bg: #fdecea;
  --amber: #b3760b;
  --amber-bg: #fdf3de;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 55, 0.05), 0 1px 3px rgba(16, 24, 55, 0.06);
  --shadow-md: 0 6px 16px rgba(16, 24, 55, 0.08), 0 2px 6px rgba(16, 24, 55, 0.05);
  --shadow-lg: 0 20px 40px rgba(10, 16, 40, 0.16), 0 6px 16px rgba(10, 16, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent-2); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d3d6e6; border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b9bdd8; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -0.015em; color: var(--text); }
h1 { font-size: 23px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Layout shells ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(124, 111, 240, 0.35), transparent 60%),
    radial-gradient(900px 600px at 85% 90%, rgba(79, 94, 234, 0.30), transparent 60%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 60%, #060a18 100%);
}
.auth-card {
  width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255,255,255,0.08);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .logo-badge {
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
  color: #fff; font-weight: 800; font-size: 19px; box-shadow: 0 8px 20px rgba(79, 94, 234, 0.35);
}
.auth-brand h1 { font-size: 21px; }

.topbar {
  height: 58px;
  background: linear-gradient(100deg, var(--navy) 0%, #16244a 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 18px;
  box-shadow: 0 2px 12px rgba(10, 16, 40, 0.18);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.topbar .brand:hover { text-decoration: none; opacity: 0.9; }
.topbar .brand .logo-badge {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(79, 94, 234, 0.5);
}
.topbar .breadcrumb { color: rgba(255,255,255,0.62); font-size: 13px; display: flex; gap: 6px; align-items: center; flex: 1; white-space: nowrap; overflow: hidden; }
.topbar .breadcrumb b { color: #fff; font-weight: 650; }
.topbar .breadcrumb a { color: rgba(255,255,255,0.62); }
.topbar .breadcrumb a:hover { color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; flex-shrink: 0; }
.topbar-right .pill { background: rgba(255,255,255,0.1); padding: 5px 12px; border-radius: 20px; font-weight: 500; border: 1px solid rgba(255,255,255,0.08); }
.topbar-right button, .topbar-right a.btn-link { color: rgba(255,255,255,0.82); font-weight: 500; transition: color .15s; }
.topbar-right a.btn-link:hover { color: #fff; text-decoration: none; }

.page-wrap { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.page-wrap.wide { max-width: 1440px; }

.app-shell { display: flex; min-height: calc(100vh - 58px); }
.sidebar {
  width: 226px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  flex-shrink: 0;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text);
  font-size: 13.5px; font-weight: 500; cursor: pointer; margin-bottom: 3px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar .nav-item:hover { background: var(--bg); text-decoration: none; }
.sidebar .nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 650; border-left-color: var(--accent); }
.main-content { flex: 1; padding: 26px 32px 64px; min-width: 0; }

/* ---------- Cards / grid ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease;
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card { padding: 18px 20px; position: relative; overflow: hidden; }
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent-gradient);
  opacity: 0.85;
}
.stat-card .label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; font-weight: 600; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--navy); letter-spacing: -0.02em; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent-red::before { background: var(--red); }
.stat-card.accent-green::before { background: var(--green); }
.stat-card.accent-amber::before { background: var(--amber); }
.stat-card.accent-red .value { color: var(--red); }
.stat-card.accent-green .value { color: var(--green); }
.stat-card.accent-amber .value { color: var(--amber); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }

/* ---------- Client / site tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
  box-shadow: var(--shadow-sm);
}
.tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #d7dbf3; text-decoration: none; }
.tile .tile-icon {
  width: 42px; height: 42px; border-radius: 12px; background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 12px; font-size: 16px;
}
.tile .tile-title { font-weight: 650; color: var(--text); font-size: 15px; }
.tile .tile-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.tile .tile-tags { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; background: var(--accent-gradient); color: #fff;
  box-shadow: 0 2px 8px rgba(79, 94, 234, 0.28);
  transition: box-shadow .15s ease, transform .1s ease, opacity .15s ease;
}
.btn:hover { box-shadow: 0 4px 14px rgba(79, 94, 234, 0.4); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.btn-secondary:hover { box-shadow: var(--shadow-md); border-color: #d7dbf3; }
.btn.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); box-shadow: none; }
.btn.btn-outline:hover { background: var(--accent-light); box-shadow: none; }
.btn.btn-danger { background: var(--red); color: #fff; box-shadow: 0 2px 8px rgba(216, 53, 42, 0.28); }
.btn.btn-danger:hover { box-shadow: 0 4px 14px rgba(216, 53, 42, 0.4); }
.btn.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; box-shadow: none; }
.btn.btn-ghost:hover { background: var(--bg); box-shadow: none; }
.btn.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; margin-top: 14px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=file], input[type=tel], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.checkbox-row input { width: auto; }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); border-bottom: 1.5px solid var(--border); padding: 10px 12px; white-space: nowrap;
  font-weight: 700; background: #fafafd;
}
thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f8f8fd; }
tbody tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; border-radius: 8px; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 34px 10px; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em; }
.badge.ok, .badge.present, .badge.closed, .badge.done { background: var(--green-bg); color: var(--green); }
.badge.issue, .badge.absent, .badge.overdue { background: var(--red-bg); color: var(--red); }
.badge.open, .badge.upcoming, .badge.leave { background: var(--amber-bg); color: var(--amber); }
.badge.in_progress, .badge.urgent { background: var(--amber-bg); color: var(--amber); }
.badge.week_off, .badge.neutral { background: #eef0f7; color: var(--text-muted); }

/* ---------- Tabs (used inside dashboard for module sub-nav) ---------- */
.tabbar { display: flex; gap: 4px; border-bottom: 1.5px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabbar .tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2.5px solid transparent; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
  transition: color .15s ease, border-color .15s ease; margin-bottom: -1.5px;
}
.tabbar .tab-btn:hover { color: var(--text); }
.tabbar .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 14, 30, 0.55); display: none;
  align-items: flex-start; justify-content: center; z-index: 100; overflow-y: auto; padding: 40px 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; animation: fadeIn .15s ease; }
.modal-box {
  background: #fff; border-radius: 18px; width: 480px; max-width: 100%; padding: 26px 28px;
  box-shadow: var(--shadow-lg); animation: slideUp .18s ease;
}
.modal-box.wide { width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-close { cursor: pointer; color: var(--text-muted); font-size: 18px; border: none; background: none; width: 28px; height: 28px; border-radius: 8px; transition: background .15s; }
.modal-close:hover { background: var(--bg); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.flex { display: flex; align-items: center; }
.flex.gap-8 { gap: 8px; }
.flex.gap-12 { gap: 12px; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.toast-container { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); min-width: 220px; animation: slideUp .18s ease;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.spinner-inline { color: var(--text-muted); font-size: 13px; padding: 24px 0; text-align: center; }
.doc-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 600; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.small-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.progress-bar { height: 9px; background: var(--border); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.progress-bar > div { height: 100%; background: var(--accent-gradient); border-radius: 6px; }
