:root {
  --navy: #0b1f33;
  --navy-2: #143049;
  --teal: #0f766e;
  --teal-light: #14b8a6;
  --sand: #e8dfd0;
  --sand-2: #f6f1e8;
  --ink: #122033;
  --muted: #5b6b7c;
  --line: #d7dde5;
  --white: #ffffff;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --info: #175cd3;
  --pending: #6941c6;
  --shadow: 0 10px 30px rgba(11, 31, 51, 0.08);
  --radius: 12px;
  --sidebar: 268px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand-2);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
a { color: var(--teal); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(24px, 5vw, 72px);
  background: var(--white);
}
.login-brand .brand-mark,
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--navy), var(--teal));
  color: white; font-weight: 800; letter-spacing: 0.02em;
}
.brand-mark.sm { width: 40px; height: 40px; border-radius: 10px; font-size: 13px; }
.login-brand h1 {
  font-family: var(--display);
  font-size: 2.6rem; font-weight: 400; margin: 18px 0 8px;
}
.login-brand p { color: var(--muted); margin: 0 0 36px; }
.login-form h2 { margin: 0 0 6px; font-size: 1.35rem; }
.login-form label {
  display: grid; gap: 6px; margin: 14px 0; font-size: 0.9rem; font-weight: 600;
}
.login-form input, .form-grid input, .form-grid select, .form-grid textarea,
.filter-bar input, .filter-bar select, .search-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; background: #fff; color: var(--ink);
}
.login-form input:focus, .form-grid input:focus, .form-grid select:focus,
.form-grid textarea:focus, .filter-bar input:focus, .filter-bar select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--teal);
}
.demo-users { margin-top: 28px; }
.demo-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.demo-user-grid { display: grid; gap: 8px; }
.demo-user-btn {
  text-align: left; border: 1px solid var(--line); background: var(--sand-2);
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.demo-user-btn:hover { border-color: var(--teal); background: #eef8f6; }
.demo-user-btn strong { display: block; font-size: 0.92rem; }
.demo-user-btn span { color: var(--muted); font-size: 0.8rem; }
.login-aside {
  background:
    linear-gradient(160deg, rgba(11,31,51,0.82), rgba(15,118,110,0.55)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath fill='%23ffffff' fill-opacity='0.04' d='M0 80h160v2H0zM80 0v160h2V0z'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #0b1f33, #0f766e);
  color: white; display: grid; place-items: center; padding: 48px;
}
.login-aside-content { max-width: 420px; }
.login-aside blockquote {
  font-family: var(--display); font-size: 2rem; line-height: 1.25; margin: 0 0 28px;
}
.login-aside ul { padding-left: 18px; opacity: 0.92; }
.login-aside li { margin: 8px 0; }

/* APP LAYOUT */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  background: var(--navy); color: #dce7f2; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar-brand {
  display: flex; gap: 12px; align-items: center; padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand strong { display: block; color: white; font-size: 0.95rem; }
.sidebar-brand span { color: #8ea3b8; font-size: 0.75rem; }
.sidebar-nav { padding: 14px 10px; display: grid; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; color: #c7d5e4;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(20, 184, 166, 0.18); color: #9ff0e4; }
.nav-item .nav-ico { width: 1.25rem; text-align: center; opacity: 0.9; }
.sidebar-footer {
  padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85rem;
}
.sidebar-footer strong { color: white; display: block; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 22px; background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 1.35rem; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.scope-pill {
  background: #e8f5f2; color: var(--teal); border: 1px solid #bfe7e0;
  padding: 6px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.content { padding: 22px; }

/* BUTTONS */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 14px;
  font-weight: 650; cursor: pointer; background: #fff; color: var(--ink);
}
.btn:hover { filter: brightness(0.98); }
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: #0d655e; }
.btn-secondary { background: var(--navy); color: white; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: #fef3f2; color: var(--danger); border-color: #fecdca; }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.icon-btn {
  border: 1px solid var(--line); background: white; border-radius: 10px;
  width: 40px; height: 40px; cursor: pointer; position: relative;
}
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px; background: var(--danger);
  color: white; border-radius: 999px; font-size: 0.65rem; min-width: 18px;
  height: 18px; display: grid; place-items: center; padding: 0 4px;
}
.mobile-only { display: none; }

/* CARDS / STATS */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card, .panel {
  background: white; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card { padding: 16px 18px; }
.stat-card .label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.stat-card .value { font-size: 1.7rem; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat-card .hint { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.panel { padding: 18px; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1.05rem; }
.stack { display: grid; gap: 16px; }

/* TABLE */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table.data {
  width: 100%; border-collapse: collapse; background: white; min-width: 720px;
}
table.data th, table.data td {
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  text-align: left; font-size: 0.9rem; vertical-align: middle;
}
table.data th {
  background: #f4f7fa; color: var(--muted); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  white-space: nowrap; cursor: pointer; user-select: none;
}
table.data tr:hover td { background: #fafcfb; }
table.data tr.clickable { cursor: pointer; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-state, .error-state, .loading-state {
  padding: 36px 18px; text-align: center; color: var(--muted);
}
.empty-state strong, .error-state strong { display: block; color: var(--ink); margin-bottom: 6px; }

/* BADGES */
.badge-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: #eef2f6; color: #344054;
  white-space: nowrap;
}
.badge-status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.st-active, .st-approved, .st-paid, .st-completed { background: #ecfdf3; color: var(--success); }
.st-pending, .st-draft, .st-calculated, .st-not-started { background: #f4f3ff; color: var(--pending); }
.st-in-progress, .st-pending-review, .st-pending-approval, .st-payable { background: #eff8ff; color: var(--info); }
.st-expiring-soon, .st-on-leave, .st-warning { background: #fffaeb; color: var(--warning); }
.st-expired, .st-rejected, .st-terminated, .st-suspended, .st-cancelled, .st-danger { background: #fef3f2; color: var(--danger); }
.st-archived { background: #f2f4f7; color: #475467; }

/* FILTERS / TOOLBAR */
.toolbar, .filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px;
}
.filter-bar label {
  display: grid; gap: 4px; font-size: 0.75rem; font-weight: 700; color: var(--muted);
  min-width: 140px;
}
.search-input { min-width: 220px; }
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 12px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted);
}
.pagination .pages { display: flex; gap: 6px; }

/* FORMS */
.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label {
  display: grid; gap: 5px; font-size: 0.82rem; font-weight: 650; color: #344054;
}
.form-error { color: var(--danger); font-size: 0.85rem; margin-top: 10px; }
.checklist { display: grid; gap: 8px; }
.checklist-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc;
}
.checklist-item .meta { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

/* DETAIL */
.detail-header {
  display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap;
}
.avatar {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(145deg, var(--navy), var(--teal));
  color: white; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
}
.avatar.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 0.8rem; }
.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.kv { padding: 10px 12px; background: #f8fafb; border-radius: 10px; border: 1px solid var(--line); }
.kv .k { font-size: 0.72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.kv .v { margin-top: 4px; font-weight: 600; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--line); background: white; border-radius: 999px;
  padding: 7px 12px; cursor: pointer; font-weight: 650; font-size: 0.85rem;
}
.tab.active { background: var(--navy); color: white; border-color: var(--navy); }

/* CHART */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 220px; }

/* MODAL */
.modal-root {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px;
}
.modal-backdrop, .drawer-backdrop {
  position: absolute; inset: 0; background: rgba(11, 31, 51, 0.45);
}
.modal {
  position: relative; width: min(720px, 100%); max-height: min(90vh, 900px);
  overflow: auto; background: white; border-radius: 16px; box-shadow: var(--shadow);
}
.modal.wide { width: min(960px, 100%); }
.modal-header, .modal-footer, .drawer-panel header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-footer { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; }
.modal-body { padding: 16px; }
.modal-header h2, .drawer-panel header h2 { margin: 0; font-size: 1.1rem; }

/* DRAWER */
.drawer { position: fixed; inset: 0; z-index: 90; }
.drawer-panel {
  position: absolute; top: 0; right: 0; width: min(400px, 100%); height: 100%;
  background: white; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.notif-list { overflow: auto; padding: 10px; flex: 1; }
.notif-item {
  padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer;
}
.notif-item.unread { background: #f0faf8; border-color: #bfe7e0; }
.notif-item .time { color: var(--muted); font-size: 0.75rem; margin-top: 4px; }

/* TOAST */
.toast-root {
  position: fixed; right: 16px; bottom: 16px; z-index: 120; display: grid; gap: 8px;
}
.toast {
  background: var(--navy); color: white; padding: 12px 14px; border-radius: 10px;
  min-width: 240px; max-width: 360px; box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
}
.toast.success { background: #065f46; }
.toast.error { background: #7f1d1d; }
@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* TIMELINE / HISTORY */
.timeline { display: grid; gap: 10px; }
.timeline-item {
  display: grid; grid-template-columns: 14px 1fr; gap: 10px;
}
.timeline-item .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--teal);
  margin-top: 5px; box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
}
.progress-bar {
  height: 8px; background: #e8eef3; border-radius: 999px; overflow: hidden;
}
.progress-bar > span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-light));
}

/* SETTINGS / MATRIX */
.matrix { overflow: auto; }
.matrix table { min-width: 640px; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.check { color: var(--success); font-weight: 800; }
.cross { color: #98a2b3; }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-105%);
    transition: transform 0.2s ease; width: min(280px, 88vw);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .scope-pill { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
