@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700&family=Poppins:wght@400;500;600&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --brand:         #2FA79B;
  --brand-bright:  #4FC9BB;
  --brand-deep:    #1E7A71;
  --brand-neon:    #12E4CF;
  --sage:          #8EB9B8;

  --paper:          #F7F9FB;
  --surface:        #FFFFFF;
  --surface-tint:   #F1F8F7;
  --border:         #B9D8D4;
  --text:           #05090A;
  --text-muted:     #5C7370;
  --text-faint:     #838383;

  --success: #2FA79B;
  --warning: #E0A32E;
  --danger:  #E05A4F;
  --info:    #3D8BD4;
  --neutral: #7A8C8A;

  --radius-card:    20px;
  --radius-control: 14px;
  --radius-pill:    999px;

  --space-xxs: 4px;  --space-xs: 8px;  --space-sm: 12px;
  --space-md: 16px;  --space-lg: 24px; --space-xl: 32px;

  --sidebar-w: 248px;
}

:root[data-theme="dark"] {
  --paper:        #05090A;
  --surface:      #0B1214;
  --surface-tint: #121C1F;
  --border:       #1E2C2E;
  --text:         #F5FAF9;
  --text-muted:   #8EB9B8;
  --text-faint:   #5C7370;

  --brand:   #4FC9BB;
  --success: #4FC9BB;
  --warning: #F5C25B;
  --danger:  #FF7A6E;
  --info:    #6BADEC;
  --neutral: #5C7370;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #05090A;
    --surface:      #0B1214;
    --surface-tint: #121C1F;
    --border:       #1E2C2E;
    --text:         #F5FAF9;
    --text-muted:   #8EB9B8;
    --text-faint:   #5C7370;

    --brand:   #4FC9BB;
    --success: #4FC9BB;
    --warning: #F5C25B;
    --danger:  #FF7A6E;
    --info:    #6BADEC;
    --neutral: #5C7370;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: 'Sora', sans-serif; font-weight: 700; margin: 0; color: var(--text); }
a { color: inherit; }
.numeric, .num, td.num, .stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-family: 'Sora', sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-md);
}
.card--accent { border-left: 3px solid var(--warning); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; line-height: 1.2;
  white-space: nowrap;
}
.chip.success { background: color-mix(in srgb, var(--success) 12%, transparent); border: 1px solid color-mix(in srgb, var(--success) 28%, transparent); color: var(--success); }
.chip.warning { background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 28%, transparent); color: var(--warning); }
.chip.danger  { background: color-mix(in srgb, var(--danger) 12%, transparent);  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);  color: var(--danger); }
.chip.info    { background: color-mix(in srgb, var(--info) 12%, transparent);    border: 1px solid color-mix(in srgb, var(--info) 28%, transparent);    color: var(--info); }
.chip.neutral { background: color-mix(in srgb, var(--neutral) 12%, transparent); border: 1px solid color-mix(in srgb, var(--neutral) 28%, transparent); color: var(--neutral); }
.chip.review  { background: color-mix(in srgb, #8B6FD4 12%, transparent); border: 1px solid color-mix(in srgb, #8B6FD4 28%, transparent); color: #8B6FD4; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  min-height: 72px; padding: 10px 18px; flex-shrink: 0;
  overflow: hidden;
  font-family: 'Sora', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: 1px;
}
.sidebar-logo { text-decoration: none; color: var(--text); }
.sidebar-logo img {
  /* Already a circle with transparent corners — no crop, no border-radius. */
  position: static; display: block;
  width: 36px; height: 36px; flex-shrink: 0;
}
.sidebar-wordmark {
  font-family: 'Sora', sans-serif;
  font-size: 15px; font-weight: 700; letter-spacing: 2px;
  color: var(--text); white-space: nowrap;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px; }
.nav-section { margin-top: 18px; }
.nav-section:first-child { margin-top: 0; }
.nav-eyebrow { padding: 0 10px; margin-bottom: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-control);
  color: var(--text-muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-tint); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); font-weight: 600; }
.nav-item .ic { width: 18px; text-align: center; font-size: 15px; }

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-tint); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: var(--brand); overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 11px; color: var(--text-muted); }
.sidebar-user form button {
  background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 15px; padding: 4px;
}
.sidebar-user form button:hover { color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; }
.topbar .scope-badge {
  font-size: 11px; font-weight: 600; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  padding: 2px 9px; border-radius: var(--radius-pill); margin-left: 10px; vertical-align: middle;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-control);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px;
}
.icon-btn:hover { color: var(--text); border-color: var(--brand); }

.content { max-width: 1440px; margin: 0 auto; padding: 28px 32px 60px; width: 100%; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 13.5px;
  padding: 9px 16px; border-radius: var(--radius-control);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--brand); color: #05090A; }
.btn-primary:hover { background: var(--brand-bright); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-control);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-family: 'Poppins', sans-serif; font-size: 13.5px;
}
textarea { font-family: 'Poppins', sans-serif; }
label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: .15s;
}
.switch .track::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: var(--surface); border-radius: 50%; transition: .15s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::before { transform: translateX(16px); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-tint); }
table.data th.num, table.data td.num { text-align: right; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-tile .stat-icon {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font-size: 15px; margin-bottom: 10px;
}
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-caption { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .grid-2, .grid-cols-2 { grid-template-columns: 1fr; } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .ic { font-size: 28px; margin-bottom: 8px; opacity: .6; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,9,10,.5); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-wide { max-width: 820px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; }

.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-control); padding: 12px 16px; font-size: 13px; min-width: 240px;
}
.toast.error { border-left-color: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
  font-family: 'Poppins', sans-serif;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }

.badge-scope {
  font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700; letter-spacing: .3px;
  background: var(--surface-tint); border: 1px solid var(--border); color: var(--text-muted);
}

.skeleton { background: linear-gradient(90deg, var(--surface-tint) 25%, var(--border) 37%, var(--surface-tint) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* An over-balance leave request. Allowed — the overage is a payroll question —
   but the approver has to see it before deciding, so the row carries a warning
   edge rather than a shout. */
tr.row-warn > td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
tr.row-warn { background: color-mix(in srgb, var(--warning) 6%, transparent); }
