/* ==========================================================================
   Roster System — Design Tokens & Base Styles
   ========================================================================== */

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

:root {
  /* Color */
  --bg:            #F6F7F9;
  --surface:       #FFFFFF;
  --surface-sunk:  #F0F1F4;
  --border:        #E4E6EA;
  --border-strong: #D3D6DC;

  --ink:           #14161A;
  --ink-soft:      #4B4F58;
  --ink-faint:     #8A8E98;

  --accent:        #3454FF;
  --accent-ink:    #1E36C9;
  --accent-soft:   #EAEEFF;

  --success:       #14875A;
  --success-soft:  #E4F6ED;
  --warning:       #B5760A;
  --warning-soft:  #FCF0DA;
  --danger:        #D6373F;
  --danger-soft:   #FCE8E9;

  /* Type */
  --font-display: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Radius / Shadow */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.05);
  --shadow-md: 0 4px 16px rgba(20, 22, 26, 0.07);
  --shadow-lg: 0 12px 32px rgba(20, 22, 26, 0.10);

  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px 0;
  color: var(--ink);
}
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 12px 0; color: var(--ink-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Layout shell ---------- */
.app-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;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px 10px;
}
.sidebar-brand .mark {
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.sidebar-brand .mark img { height: 100%; width: auto; display: block; }
.sidebar-brand .name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar-brand .sub {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: -2px;
}

.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  padding: 0 10px;
  margin-bottom: 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--surface-sunk); text-decoration: none; color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-link .ico { width: 17px; text-align: center; opacity: 0.85; }

.nav-submenu { margin-bottom: 2px; }
.nav-submenu summary.nav-link {
  cursor: pointer;
  list-style: none;
  justify-content: space-between;
  margin-bottom: 0;
}
.nav-submenu summary.nav-link::-webkit-details-marker { display: none; }
.nav-submenu summary.nav-link::marker { content: ''; }
.nav-submenu summary.nav-link .label { display: flex; align-items: center; gap: 10px; }
.nav-submenu summary.nav-link .chevron { transition: transform 0.15s ease; opacity: 0.6; font-size: 11px; }
.nav-submenu[open] > summary.nav-link .chevron { transform: rotate(90deg); }
.nav-submenu-items { padding-left: 15px; border-left: 1px solid var(--border); margin: 2px 0 2px 22px; }
.nav-submenu-items .nav-link { font-size: 13px; padding: 7px 10px; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-family: var(--font-display);
  flex-shrink: 0;
}
.user-chip .who { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.user-chip .role { font-size: 11px; color: var(--ink-faint); }
.logout-link { display: block; font-size: 12px; color: var(--ink-faint); margin-left: 37px; margin-top: 4px; }

/* ---------- Main content ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
  height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-size: 12.5px; color: var(--ink-faint); }
.topbar .title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 28px; max-width: 1320px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-head p { margin: 0; font-size: 13.5px; }

/* ---------- Cards / Surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-header h3 { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-body); font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.12s ease;
  line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); text-decoration: none; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-sunk); text-decoration: none; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #f8d3d5; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-sunk); text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], select, textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 13.5px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.week-grid th { text-align: center; padding: 8px 6px; font-size: 12px; color: var(--ink-soft); border-bottom: 1px solid var(--border); }
.week-grid th.is-today { color: var(--accent-ink); }
.week-grid td { text-align: center; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.week-grid td.is-today { background: var(--accent-soft); }
.week-grid-count {
  position: relative;
  display: inline-block;
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  cursor: default;
}
.week-grid-count.is-ok { background: var(--success-soft); color: var(--success); }
.week-grid-count.is-short { background: var(--danger-soft); color: var(--danger); }
.week-grid-count:hover::after {
  content: attr(data-names);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: pre;
  text-align: left;
  line-height: 1.6;
  min-width: 110px;
  z-index: 30;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  pointer-events: none;
}
.week-grid-count:hover::before {
  content: '';
  position: absolute;
  bottom: 118%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #222;
  z-index: 30;
  pointer-events: none;
}

.week-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.week-nav-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  border: 1px solid var(--border); color: var(--ink-soft); font-size: 16px;
  text-decoration: none;
}
.week-nav-btn:hover { background: var(--surface-sunk); text-decoration: none; }
.week-nav-label { font-size: 13.5px; font-weight: 600; color: var(--ink); min-width: 150px; text-align: center; }
.week-nav-today { font-size: 12.5px; color: var(--accent-ink); text-decoration: none; margin-left: 4px; }
.week-nav-today:hover { text-decoration: underline; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-faint);
  padding: 10px 22px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 13px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-sunk); }
td.num { font-variant-numeric: tabular-nums; }

/* ---------- Badges / Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 100px;
}
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger  { background: var(--danger-soft); color: var(--danger); }
.pill-neutral { background: var(--surface-sunk); color: var(--ink-soft); }
.pill-accent  { background: var(--accent-soft); color: var(--accent-ink); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-state .ico { font-size: 30px; margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,22,26,0.42);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px;
  max-height: 88vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-close { cursor: pointer; color: var(--ink-faint); font-size: 18px; line-height: 1; background: none; border: none; }

/* ---------- Toast / Alert ---------- */
.alert {
  padding: 12px 16px; border-radius: var(--r-sm);
  font-size: 13px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #EEF1FF 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.login-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(155deg, var(--accent), var(--accent-ink));
  margin-bottom: 18px;
}
.login-card h1 { font-size: 21px; }
.login-card > p { font-size: 13px; margin-bottom: 26px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.text-faint { color: var(--ink-faint); }
.text-sm { font-size: 12.5px; }
.w-full { width: 100%; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 18px; }
}
