:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --danger: #ef4444;
  --off: #f1f5f9;
  --holiday-bg: #fef3c7;
  --holiday-ink: #b45309;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --cell-w: 1.62rem; /* +20% from 1.35rem */
  --cell-h: 2.4rem;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 3.5rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar a { color: var(--muted); font-weight: 500; transition: color 0.15s; }
.topbar a:hover { color: var(--brand); text-decoration: none; }
.topbar .brand { display: inline-flex; align-items: center; font-weight: 800; font-size: 1.15rem; color: var(--ink); letter-spacing: -0.02em; }
.topbar .brand:hover { text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 0.25rem; margin-left: 1.5rem; }
.topbar nav a {
  padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.875rem; transition: all 0.15s;
}
.topbar nav a:hover { background: #f1f5f9; color: var(--ink); text-decoration: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

/* Year Selector */
.year-selector {
  display: flex; align-items: center; gap: 0.5rem;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: 0.3rem 0.6rem; transition: border-color 0.15s;
}
.year-selector:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.year-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.year-select {
  border: none; background: transparent; font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--ink); cursor: pointer; outline: none; padding: 0.1rem 0; min-width: 3.5rem;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center; padding-right: 1rem;
}
.btn-logout { font-size: 0.8rem !important; padding: 0.35rem 0.75rem !important; color: var(--muted) !important; }
.btn-logout:hover { color: var(--danger) !important; border-color: #fecaca !important; background: #fef2f2 !important; }
main { padding: 1.5rem 2rem; max-width: 100%; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.toolbar h1 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; color: var(--ink); }
.actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
}
.btn:hover { border-color: #cbd5e1; transform: translateY(-1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.flash {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #14532d;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.flash.error { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.muted { color: var(--muted); font-size: 0.9rem; }
.legend { 
  display: flex; gap: 1.25rem; flex-wrap: wrap; 
  margin-bottom: 1.5rem; 
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.8rem; 
  color: var(--muted);
  box-shadow: var(--shadow);
}
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend .dot, .dot {
  display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #94a3b8;
}
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.2rem; height: 1.2rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600;
}
.chip-full { background: var(--brand); color: #fff; }
.chip-half { background: #bfdbfe; color: #1e40af; }
.chip-off { background: var(--off); color: var(--muted); }

/* Planning Table - Single Annual View */
.grid-wrap { 
  overflow-x: auto; 
  background: var(--card); 
  border: 1px solid var(--line); 
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.grid-wrap::-webkit-scrollbar { height: 8px; }
.grid-wrap::-webkit-scrollbar-track { background: transparent; }
.grid-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

table.planning, table.sheet, table.simple {
  border-collapse: separate; 
  border-spacing: 0;
  background: var(--card);
  width: max-content;
}
table.planning th, table.planning td,
table.sheet th, table.sheet td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  width: var(--cell-w); 
  min-width: var(--cell-w); 
  height: var(--cell-h);
  text-align: center; 
  font-size: 0.75rem; 
  padding: 0;
  transition: background 0.1s;
}
/* Remove outer borders for cleaner look */
table.planning tr:last-child td { border-bottom: none; }
table.planning th:last-child, table.planning td:last-child { border-right: none; }

table.planning .name-col, table.sheet .name-col, table.simple th:first-child {
  position: sticky; left: 0; z-index: 10; 
  background: var(--card);
  text-align: left; 
  padding: 0 0.75rem; 
  min-width: 9rem; 
  width: 9rem;
  font-weight: 600;
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.05);
}
table.planning .name-col a { color: var(--ink); }
table.planning .name-col a:hover { color: var(--brand); text-decoration: none; }

table.planning .total-col, table.sheet .total-col {
  position: sticky; right: 0; z-index: 10;
  min-width: 3.5rem; width: 3.5rem; 
  font-weight: 700; 
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -2px 0 4px -2px rgba(0,0,0,0.05);
  color: var(--ink);
}

/* Month Headers */
table.planning th.month-header {
  background: #f8fafc; 
  font-size: 0.75rem; 
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0;
  border-bottom: 2px solid var(--line);
}
table.planning th.day-header {
  background: #fff;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.25rem 0;
}

td.weekend, th.weekend { background: var(--off); color: #94a3b8; }
td.holiday, th.holiday { background: var(--holiday-bg); color: var(--holiday-ink); }
td.invalid, th.invalid { background: #fafafa; color: transparent; pointer-events: none; }
td.leave { 
  background: color-mix(in srgb, var(--c, #888) 25%, white); 
  position: relative;
}
td.leave::after {
  content: '';
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--c, #888);
}
/* Sections */
section.quarter {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow);
}
section.quarter h2 {
  margin: 0 0 1rem; font-size: 1.1rem; font-weight: 700; color: var(--ink);
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--line);
}

/* Simple Tables */
table.simple {
  width: 100%; margin-top: 0.75rem; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.simple thead th {
  background: #f8fafc; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); padding: 0.65rem 0.85rem; text-align: left;
  border-bottom: 2px solid var(--line);
}
table.simple tbody td, table.simple tbody th {
  padding: 0.6rem 0.85rem; text-align: left; font-size: 0.875rem; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
table.simple tbody tr:last-child td, table.simple tbody tr:last-child th { border-bottom: none; }
table.simple tbody tr:hover { background: #f8fafc; }

/* Sheet Table (Employee) */
table.sheet {
  border-collapse: separate; border-spacing: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); width: max-content; margin-bottom: 1.5rem;
}
table.sheet th, table.sheet td {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  width: var(--cell-w); min-width: var(--cell-w); height: var(--cell-h);
  text-align: center; font-size: 0.75rem; padding: 0;
}
table.sheet tr:last-child td { border-bottom: none; }
table.sheet th:last-child, table.sheet td:last-child { border-right: none; }
table.sheet thead th {
  background: #f8fafc; font-weight: 600; color: var(--muted); font-size: 0.7rem;
  padding: 0.4rem 0; border-bottom: 2px solid var(--line);
}
table.sheet tfoot th {
  background: #f8fafc; font-weight: 700; border-top: 2px solid var(--line);
}
.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.25rem; min-width: 9rem;
  box-shadow: var(--shadow);
}
.card .label { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.25rem; }
.card strong { font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.card-accent { border-left: 3px solid var(--brand); }
.card-solde { border-left: 3px solid #16a34a; }
.card-link {
  text-decoration: none !important; color: inherit; transition: all 0.15s; cursor: pointer; display: block;
}
.card-link:hover { border-color: var(--brand); box-shadow: 0 4px 12px rgba(59,130,246,0.12); transform: translateY(-2px); }
.note-banner {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius);
  padding: 0.6rem 1rem; margin-bottom: 1.25rem; font-size: 0.875rem; color: #92400e;
}
.form-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; max-width: 40rem; display: grid; gap: 1rem;
  box-shadow: var(--shadow);
}
.form-card label { display: grid; gap: 0.35rem; font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.form-card input[type="text"],
.form-card input[type="number"],
.form-card input[type="date"],
.form-card input[type="password"],
.form-card select {
  padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 6px; font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-card input:focus, .form-card select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-card .row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-card .row label { flex: 1 1 10rem; }
.form-card .check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.inline { display: inline; }
.steps { line-height: 1.7; color: var(--muted); }
pre {
  background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: var(--radius); overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.85rem;
}
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-box {
  background: var(--card); padding: 2.5rem; border-radius: 16px; width: min(24rem, 92vw);
  display: grid; gap: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
}
.login-box h1 { margin: 0 0 0.5rem; font-size: 1.5rem; text-align: center; }
.login-box label { display: grid; gap: 0.35rem; font-size: 0.875rem; font-weight: 500; }
.login-box input {
  padding: 0.65rem 0.75rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  transition: all 0.15s;
}
.login-box input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.login-box button {
  padding: 0.75rem; border: 0; border-radius: 8px; background: var(--brand); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; transition: background 0.15s; margin-top: 0.5rem;
}
.login-box button:hover { background: var(--brand-hover); }
.flash {
  background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
  padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  font-size: 0.9rem; font-weight: 500;
}
.flash.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.muted { color: var(--muted); font-size: 0.875rem; }

/* Clickable cells */
table.planning td.clickable { cursor: pointer; }
table.planning td.clickable:hover { background: #eef2ff; outline: 2px solid var(--brand); outline-offset: -2px; z-index: 5; position: relative; }
table.planning td.leave.clickable:hover { outline-color: var(--c, var(--brand)); }

/* Context Menu */
.ctx-menu {
  position: fixed; z-index: 1000;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.12), 0 4px 10px rgba(0,0,0,0.08);
  min-width: 12rem; padding: 0.35rem 0;
  font-size: 0.85rem;
  animation: ctxFadeIn 0.12s ease-out;
}
@keyframes ctxFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.ctx-menu-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.85rem; cursor: pointer; color: var(--ink); transition: background 0.1s;
}
.ctx-menu-item:hover { background: #eff6ff; }
.ctx-menu-item .ctx-icon { width: 1rem; text-align: center; font-size: 0.75rem; }
.ctx-menu-sep { height: 1px; background: var(--line); margin: 0.25rem 0; }
.ctx-menu-header { padding: 0.35rem 0.85rem 0.2rem; font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

@media print {
  .topbar, .toolbar .actions, .legend, .btn, .ctx-menu { display: none !important; }
  main { padding: 0; }
  .grid-wrap { box-shadow: none; border: none; overflow: visible; }
  table.planning { width: 100%; }
}
