:root {
    --ink: #111;
    --muted: #6b7280;
    --line: #e5e7eb;
}
/* ==================== BASE / RESET ==================== */
body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Helvetica, Arial, sans-serif;
    margin: 0;
    background: #f6f7f9;
    color: var(--ink);
}
/* ==================== BADGES ==================== */
.badge-invited { background: #fef3c7; color: #92400e; padding: 2px 6px; border-radius: 4px; }
.badge-active { background: #d1fae5; color: #065f46; padding: 2px 6px; border-radius: 4px; }
.badge-disabled { background: #f3f4f6; color: #374151; padding: 2px 6px; border-radius: 4px; }
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    background: #eef;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .03em;
}
/* ==================== LAYOUT WRAPPER ==================== */
.wrap { max-width: 1024px; margin: 24px auto; padding: 0 16px; }
.narrow { max-width: 480px; margin: 24px auto; }
.weekgrid, .sticky-top, .btns-container { width: 100%; max-width: 1024px; margin: 0 auto; }
header { display: none; }
/* ==================== NAV / HEADER ==================== */
.nav-dark {
    background: #111;
    color: #fff;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}
.nav-dark .auth {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    justify-content: flex-start;
}
.nav-dark .small-muted { color: #ddd; font-size: 13px; }
#loginForm {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    width: 100%;
}
#loginForm input[type="email"],
#loginForm input[type="password"] {
    flex: 1 1 0;
    min-width: 0;
}
#loginForm button {
    white-space: nowrap;
}
@media (max-width: 700px) {
    /* Make login drop to its own row under the title */
    .nav-dark > div:first-child { flex: 1 1 100%; }
    .nav-dark .auth { flex: 1 1 100%; justify-content: flex-start; }
    #loginForm { flex-direction: column; align-items: stretch; }
    #loginForm input[type="email"],
    #loginForm input[type="password"],
    #loginForm button { width: 100%; }
}
/* ==================== TYPO / BADGES / UTILS ==================== */
.small { font-size: 0.8em; color: var(--muted); }
.bold { font-weight: bold; }
.muted { color: var(--muted); }
.pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    background: #fff;
    color: #111;
    text-decoration: none;
    display: inline-block;
}
.pill-active { background: #111; border-color: #111; color: #fff; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
/* ==================== BUTTONS ==================== */
.btn {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 8px;
    background: #111;
    color: #fff;
    text-decoration: none;
    border: none;
    cursor: pointer;
}
.btn-secondary { background: #4b5563; color: #fff; }
.btn-slim { padding: 4px 8px; font-size: 12px; }
/* ==================== WARNINGS ==================== */
.thead-warn { background: #7f1d1d !important; color: white; }
.thead-warn th { border-color: #7f1d1d; background: #7f1d1d !important; }
/* ==================== CARDS ==================== */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
/* ==================== TABLES ==================== */
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid var(--line); padding: 8px 10px; font-size: 14px; }
th { background: #f1f5f9; text-align: left; }
tfoot td { font-weight: 600; background: #fafafa; }
th:first-child, td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
thead th:first-child { z-index: 2; background: #f1f5f9; }
.row-canceled { background: #fff7f7; }
/* ==================== FORMS / INPUTS ==================== */
input[type="text"], input[type="time"], input[type="date"], input[type="number"], input[type="email"], input[type="password"], select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
select { font-size: 13px; }
.auth { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.auth form { margin: 0; }
/* ==================== STATUS SELECT + CELL LAYOUT ==================== */
.status-select { width: auto; min-width: 90px; max-width: 100%; }
@media (max-width: 600px) { .status-select { width: 100%; } }
.cell-inline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cell-inline .amount { font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
    .cell-inline { flex-direction: column; align-items: flex-end; gap: 4px; }
    .cell-inline .amount { align-self: flex-end; }
}
/* ==================== GRID HELPERS ==================== */
.form-grid { display: grid; gap: 8px; }
@media (min-width: 600px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 10px 0 2px;
}
/* ==================== WEEK GRID (ADMIN) ==================== */
.weekgrid { display: grid; gap: 8px; grid-template-columns: repeat(7, minmax(0, 1fr)); background: #fff; }
.weekwrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
/* Collapsed state handled via class to avoid Safari/iOS grid repaint bugs */
.weekbar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px 0; }
.weekbar-title { font-weight: 600; font-size: 14px; color: #111; }
.weekfilters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; }
.weekcol { display: flex; flex-direction: column; gap: 6px; }
.weekhead {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #374151;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 4px;
    margin-bottom: 2px;
}
.weekcol-list { display: flex; flex-direction: column; gap: 6px; }
.weekitem {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    background: #fafafa;
}
.weekitem:hover { background: #f3f4f6; }
.weekitem.current { background: #e5e7eb; border-color: #cbd5e1; }
.weekitem.missing-attendance { background: #fff7cc; border-color: #facc15; }
.weektime {
    font-feature-settings: 'tnum' 1;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: #111;
}
.weekname {
    font-size: 12px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.icon-toggle { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px 8px; cursor: pointer; }
.icon-toggle.open { transform: rotate(90deg); }
/* ==================== STICKY TOP ==================== */
.sticky-top { position: sticky; top: 0; background: #f6f7f9; padding: 8px 0; z-index: 3; }
/* ==================== DOTS (SESSION STATE) ==================== */
.sum-cell { border-width: 0.5px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 999px; border: 1px solid #d1d5db; vertical-align: middle; }
.dot-green { background: #10b981; border-color: #10b981; }
.dot-red { background: #ef4444; border-color: #ef4444; }
/* ==================== PRESENCE INTENSITY (GREEN SHADES) ==================== */
.st-pres { position: relative; }
.st-pres-1 { background: rgba(0,0,0,0.15); }
.st-pres-2 { background: rgba(0,0,0,0.12); }
.st-pres-3 { background: rgba(0,0,0,0.09); }
.st-pres-4 { background: rgba(0,0,0,0.06); }
.st-pres-5 { background: rgba(0,0,0,0.03); }
/* ==================== DIALOGS ==================== */
dialog { border: none; border-radius: 10px; padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
dialog::backdrop { background: rgba(0,0,0,.25); }
/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) { .weekgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .weekgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 768px) {
    th, td { padding: 6px 8px; font-size: 13px; }
    .wrap { padding: 0 8px; }
    .sticky-top { position: static; }
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ==================== INVOICE PAGES ==================== */
.a4 {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 18mm 16mm;
    box-sizing: border-box;
    background: #fff;
}
.a4 h1 {
    font-size: 20px;
    margin: 0 0 6px 0;
}
.a4 h2 {
    font-size: 14px;
    margin: 16px 0 6px 0;
    color: var(--muted);
}
.invoice-grid,
.a4 .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.a4 .card {
    padding: 12px;
}
.a4 table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.a4 table th,
.a4 table td {
    border-bottom: 1px solid var(--line);
    border-left: none;
    border-right: none;
}
.a4 table th {
    background: #f8fafc;
}
.a4 table tfoot td {
    font-weight: 600;
}
.mt8 {
    margin-top: 8px;
}
.mt16 {
    margin-top: 16px;
}
.btnprint {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #111;
    color: #fff;
    text-decoration: none;
}
.login-warning {
  background: #fde68a;
  color: #78350f;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  border: 1px solid #fcd34d;
}
@media print {
    .btnprint {
        display: none;
    }
    .a4 {
        padding: 0;
        margin: 0;
    }
    @page {
        size: A4;
        margin: 18mm;
    }
}