:root {
    color-scheme: light;
    --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --ink: #111827;
    --ink2: #374151;
    --muted: #6B7280;
    --line: #E5E7EB;
    --line2: #F1F5F9;
    --bg: #F8FAFC;
    --navy: #1F2937;
    --navy2: #374151;
    --accent: #4F6FA5;
    --accent-dark: #34527F;
    --accent-soft: #E8EEF7;
    --ok: #15803D;
    --ok-bg: #E7F4EC;
    --warn: #B45309;
    --warn-bg: #FBEFD9;
    --err: #B91C1C;
    --err-bg: #FBE7E7;
    --neutral: #4B5563;
    --neutral-bg: #F1F3F5;
    --surface: #fff;
    --hover: #F9FAFB;
    --line-strong: #D1D5DB;
    --link: var(--accent);
    --ok-line: #BBE3C9;
    --warn-line: #EBD3A4;
    --err-line: #F2C5C5;
    --switch-off: #D1D5DB;
    --day-out: #C0C6CF;
    --nav-active: var(--navy);
}

/* Dark theme: switched by <html data-theme="dark"> (see layouts/partials/theme-init.blade.php). */
:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #E6EAF0;
    --ink2: #C9D1DC;
    --muted: #96A0AE;
    --line: #2A3342;
    --line2: #202836;
    --bg: #0E131A;
    --surface: #161C26;
    --hover: #1D2531;
    --line-strong: #3A4558;
    --navy: #0A0E14;
    --navy2: #1A212C;
    --accent-dark: #A9C2EA;
    --accent-soft: #1F2B42;
    --link: #7FA0D6;
    --ok: #4ADE80;
    --ok-bg: #12301F;
    --ok-line: #1E5434;
    --warn: #FBBF24;
    --warn-bg: #33270E;
    --warn-line: #5C4516;
    --err: #F87171;
    --err-bg: #381616;
    --err-line: #6B2626;
    --neutral: #A3ADBB;
    --neutral-bg: #232B38;
    --switch-off: #475569;
    --day-out: #6B7686;
    --nav-active: #E6EAF0;
}

.erp-body { margin: 0; background: var(--bg); }

.erp {
    display: flex;
    min-height: 100vh;
    font: 400 14px/1.43 var(--font);
    color: var(--ink);
    background: var(--bg);
}
.erp *, .auth-wrap * { box-sizing: border-box; }

.logo {
    width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 500; flex: 0 0 auto;
}

.erp-sidebar {
    flex: 0 0 256px; width: 256px; background: var(--navy); padding: 20px 12px;
    display: flex; flex-direction: column; gap: 24px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.erp-brand { display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.erp-brand-logo {
    display: block;
    width: 100%;
    max-width: 180px;
    height: 64px;
    object-fit: contain;
}
.erp-nav { display: flex; flex-direction: column; gap: 4px; }
.erp-nav a {
    display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 6px;
    font-size: 14px; font-weight: 500; color: #D1D5DB; text-decoration: none;
}
.erp-nav a:hover { background: var(--navy2); color: #fff; }
.erp-nav a.active { background: var(--accent-soft); color: var(--nav-active); }
.erp-org {
    margin-top: auto; padding: 12px; border-radius: 8px; background: var(--navy2);
    color: #D1D5DB; font-size: 12px; line-height: 1.5;
}
.erp-org b { display: block; color: #fff; font-weight: 500; margin-bottom: 2px; }

.erp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.erp-topbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 0 32px; min-height: 64px;
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.erp-search { position: relative; flex: 1 1 280px; max-width: 420px; }
.erp-search svg { position: absolute; left: 12px; top: 12px; }
.erp-search input {
    width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
    padding: 0 12px 0 36px; font: 400 14px var(--font);
}
.erp-spacer { flex: 1 1 0; }
.iconbtn {
    position: relative; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface);
    border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--ink2); cursor: pointer;
}
.iconbtn .ping {
    position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 999px;
    background: var(--err); border: 2px solid var(--surface);
}
.erp-user { display: flex; align-items: center; gap: 10px; }
.erp-user .who { display: flex; flex-direction: column; line-height: 1.25; }
.erp-user .who b { font-weight: 500; font-size: 14px; }
.erp-user .who span { font-size: 12px; color: var(--muted); }
.avatar {
    width: 36px; height: 36px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 13px; flex: 0 0 auto;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.erp-content { padding: 32px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head h2 { color: var(--ink) !important; }
.crumb { font-size: 13px; color: var(--muted); }
.page-title { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.3; color: var(--ink); }
.page-sub { color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
    height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink2);
    border-radius: 6px; font: 500 14px var(--font); display: inline-flex; align-items: center;
    gap: 8px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-lg { height: 44px; padding: 0 24px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.link { color: var(--link); font-weight: 500; text-decoration: none; }
.link:hover { color: var(--accent-dark); text-decoration: underline; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card-pad { padding: 20px 24px; }
.card-head {
    display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
    padding: 14px 24px; border-bottom: 1px solid var(--line);
}
.card-title { margin: 0; font-size: 16px; font-weight: 500; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { color: var(--muted); font-weight: 500; }
.kpi-icon {
    width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center;
}
.kpi-value { font-size: 32px; font-weight: 500; letter-spacing: -0.02em; line-height: 1; }
.kpi-note { font-size: 13px; color: var(--muted); }

.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--accent-soft); color: var(--accent-dark); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }

.t-scroll { overflow-x: auto; }
.t-min { min-width: 760px; }
.t-head, .t-row {
    display: grid; grid-template-columns: var(--cols); gap: 12px; padding: 0 20px; align-items: center;
}
.t-head {
    height: 40px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 12px;
    font-weight: 500; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase;
}
.t-row { min-height: 60px; border-bottom: 1px solid var(--line2); }
.t-row:last-child { border-bottom: 0; }
.t-name { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.t-right { text-align: right; }
.t-empty { padding: 32px; text-align: center; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink2); }
.input, .select {
    height: 40px; width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 12px;
    background: var(--surface); font: 400 14px var(--font); color: var(--ink);
}
.input:focus, .select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-error { font-size: 12px; color: var(--err); }
.filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; padding: 16px 20px; }
.filters .field { min-width: 220px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink2); cursor: pointer; user-select: none; }

/* Checkboxes: a rounded box with a drawn tick instead of the browser default */
.check input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 20px; height: 20px; margin: 0;
    display: inline-grid; place-content: center; cursor: pointer;
    border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--surface);
    transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.check input[type="checkbox"]::after {
    content: ''; width: 12px; height: 12px; transform: scale(0); transition: transform .12s ease-out;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.5'/%3E%3C/svg%3E");
}
.check input[type="checkbox"]:hover:not(:disabled) { border-color: var(--accent); }
.check input[type="checkbox"]:checked { background-color: var(--accent); border-color: var(--accent); }
.check input[type="checkbox"]:checked::after { transform: scale(1); }
.check input[type="checkbox"]:indeterminate { background-color: var(--accent); border-color: var(--accent); }
.check input[type="checkbox"]:indeterminate::after { transform: scale(1); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M4 8h8'/%3E%3C/svg%3E"); }
.check input[type="checkbox"]:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1.5px var(--accent); }
.check input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
.check:has(input:disabled) { cursor: not-allowed; color: var(--muted); }

/* Choosing several of a few options (days, branches): each option becomes a tile that lights up when ticked */
.check-row .check {
    padding: 9px 14px 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
    color: var(--ink); font-size: 14px; transition: background-color .12s, border-color .12s;
}
.check-row .check:hover { background: var(--hover); }
.check-row .check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 500; }
.check-row .check:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-soft); }

.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid; font-size: 14px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.alert-err { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
    position: relative; height: 36px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink2); font: 500 13px var(--font); display: inline-flex;
    align-items: center; cursor: pointer; white-space: nowrap;
}
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
.pill.on.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.pill.on.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.pill.on.err { background: var(--err-bg); border-color: var(--err); color: var(--err); }
.pill.on.info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }
.att-summary { font-size: 13px; color: var(--ink2); }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }

.split { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-end; }
.chart { flex: 1 1 280px; display: flex; align-items: flex-end; gap: 16px; height: 190px; border-bottom: 1px solid var(--line); }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.chart-pct { font-size: 12px; font-weight: 500; color: var(--ink2); }
.chart-bar { width: 100%; max-width: 44px; border-radius: 4px 4px 0 0; background: var(--accent); }
.chart-bar.empty { background: var(--line); }
.chart-days { display: flex; gap: 16px; font-size: 12px; color: var(--muted); max-width: 460px; }
.chart-days span { flex: 1; text-align: center; }
.sum-list { flex: 0 1 200px; display: flex; flex-direction: column; gap: 12px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 500; }

.auth-wrap {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 24px; padding: 24px; background: var(--bg); font: 400 14px/1.43 var(--font); color: var(--ink);
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 18px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 32px; }
.auth-title { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.auth-sub { margin: 0 0 24px; color: var(--muted); }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.progress { height: 12px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.level-card { display: flex; flex-wrap: wrap; align-items: center; gap: 32px; padding: 24px; }
.level-badge {
    width: 72px; height: 72px; border-radius: 999px; background: var(--accent); color: #fff; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 500;
}
.level-body { flex: 1 1 280px; min-width: 0; }
.level-title { font-size: 18px; font-weight: 500; }
.level-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.streak { text-align: center; }
.streak .n { font-size: 28px; font-weight: 500; line-height: 1.2; }
.achv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.achv {
    --medal-from: #F6E3CF; --medal-to: #E8C4A0; --medal-ring: #C98A50;
    position: relative; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
    padding: 26px 14px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.achv.silver { --medal-from: #F3F4F6; --medal-to: #D5DAE1; --medal-ring: #9AA3AF; }
.achv.gold { --medal-from: #FFF3C4; --medal-to: #F7D56B; --medal-ring: #D9A21B; }
.achv .ico {
    width: 64px; height: 64px; border-radius: 999px; font-size: 28px; margin-bottom: 4px;
    background: linear-gradient(135deg, var(--medal-from), var(--medal-to));
    box-shadow: inset 0 0 0 3px var(--medal-ring), 0 4px 10px rgba(17, 24, 39, .12);
    display: flex; align-items: center; justify-content: center;
}
.achv-tier {
    position: absolute; top: 10px; right: 10px; padding: 2px 8px; border-radius: 999px;
    font-size: 10px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
    background: var(--medal-from); color: #4B5563; box-shadow: inset 0 0 0 1px var(--medal-ring);
}
.achv b { font-size: 14px; font-weight: 500; }
.achv-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.achv-status { margin-top: 4px; font-size: 11px; font-weight: 500; color: var(--ok); }
.achv.locked { background: var(--bg); }
.achv.locked .ico { filter: grayscale(1); opacity: .5; }
.achv.locked b, .achv.locked .achv-desc, .achv.locked .achv-tier { opacity: .6; }
.achv.locked .achv-status { color: var(--muted); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
    padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
    color: var(--muted); font-weight: 500; text-decoration: none;
}
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.t-row.me { background: var(--accent-soft); }
.rank { font-weight: 500; color: var(--link); }
.input-sm { height: 36px; width: 96px; }

.textarea {
    width: 100%; min-height: 120px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 10px 12px;
    font: 400 14px/1.5 var(--font); color: var(--ink); background: var(--surface); resize: vertical;
}
.textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-hint { font-size: 12px; color: var(--muted); }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.label-up { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 4px; }
.quote { border-left: 3px solid var(--line); padding: 2px 12px; color: var(--ink2); white-space: pre-line; }
.file-chip {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line);
    border-radius: 8px; background: var(--bg);
}
.file-ext {
    width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500;
    text-transform: uppercase; flex: 0 0 auto;
}
.file-chip .meta { flex: 1; min-width: 0; }
.file-chip .meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .meta span { font-size: 12px; color: var(--muted); }
.file-chip.is-removed { opacity: .55; }
.file-chip.is-removed .meta b { text-decoration: line-through; }
.dropzone {
    border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 28px; text-align: center; background: var(--bg);
    display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted);
}
.review-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
.stu-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line2);
    color: inherit; text-decoration: none;
}
.stu-row:last-child { border-bottom: 0; }
.stu-row.sel { background: var(--accent-soft); }
.stu-row .nm { flex: 1; min-width: 0; font-weight: 500; }
.stu-row .when { font-size: 12px; color: var(--muted); font-weight: 400; }
.acard { padding: 20px 24px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
.acard h3 { margin: 0; font-size: 16px; font-weight: 500; }
.acard p { margin: 6px 0; color: var(--ink2); }
.due { text-align: right; }
.due small { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; font-weight: 500; }
.grade { font-size: 20px; font-weight: 500; }
@media (max-width: 1100px) { .review-grid { grid-template-columns: 1fr; } }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.check-row { display: flex; flex-wrap: wrap; gap: 16px 24px; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }

.bar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 90px; gap: 12px; align-items: center; }
.bar-row .name { font-weight: 500; }
.bar-row .val { text-align: right; font-size: 13px; color: var(--ink2); }
.chart-days.wide { max-width: none; }
.chart.wide { max-width: none; }

.iconbtn { text-decoration: none; }
.iconbtn .count {
    position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--err); color: #fff; font-size: 11px; font-weight: 500; line-height: 18px; text-align: center;
}
.notif {
    display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 16px 20px; border: 0;
    border-bottom: 1px solid var(--line2); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer;
    font: 400 14px/1.43 var(--font);
}
.notif:hover { background: var(--bg); }
.notif.unread { background: var(--accent-soft); }
.notif b { display: block; font-weight: 500; }
.notif-body { display: block; color: var(--ink2); }
.notif-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 999px; background: var(--accent); flex: 0 0 auto; }
.notif-dot.off { background: transparent; }
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }

.status-toggle { display: flex; align-items: center; gap: 10px; margin: 0; }
.switch {
    position: relative; flex: 0 0 auto; width: 34px; height: 20px; padding: 0; border: 0; border-radius: 999px;
    background: var(--switch-off); cursor: pointer; transition: background .15s;
}
.switch::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch.on { background: #16A34A; }
.switch.on::after { transform: translateX(14px); }
.status-label { font-size: 13px; color: var(--muted); }
.status-label.on { color: var(--ok); }

/* ------------------------------------------------------------------ responsive */
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
.erp-menu, .erp-sidebar-close, .erp-logout-mobile, .erp-overlay { display: none; }

/* Tablet and below: the sidebar becomes an off-canvas drawer */
@media (max-width: 1024px) {
    .erp { flex-direction: column; }
    .erp-sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(86vw, 300px); height: 100dvh;
        padding: 16px 12px; transform: translateX(-100%); visibility: hidden;
        transition: transform .22s ease, visibility 0s linear .22s;
        box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    }
    .erp.nav-open .erp-sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
    .erp-overlay { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(17, 24, 39, .55); }
    .erp.nav-open { overflow: hidden; }

    .erp-menu { display: flex; flex: 0 0 auto; }
    .erp-sidebar-close {
        display: flex; align-items: center; justify-content: center; position: absolute; top: 12px; right: 12px;
        width: 36px; height: 36px; border: 0; border-radius: 6px; background: transparent; color: #D1D5DB; cursor: pointer;
    }
    .erp-sidebar-close:hover { background: var(--navy2); color: #fff; }
    .erp-logout-mobile { display: block; margin: 0; }
    .erp-logout-mobile .btn { width: 100%; justify-content: center; background: transparent; color: #E5E7EB; border-color: #4B5563; }
    .erp-logout-mobile .btn:hover { background: var(--navy2); }
    .erp-org { margin-top: 0; }
    .erp-nav { overflow-y: auto; }
    .erp-nav a { height: 44px; }

    .erp-topbar {
        position: sticky; top: 0; z-index: 30; padding: 10px 20px; gap: 12px; min-height: 60px;
    }
    .erp-search { order: 10; flex: 1 1 100%; max-width: none; }
    .erp-user .who, .erp-topbar .erp-logout { display: none; }
    .erp-topbar .select { min-width: 0 !important; max-width: 200px; }
    .erp-content { padding: 24px 20px; gap: 20px; }
}

/* Large phones and small tablets: tables turn into stacked cards */
@media (max-width: 768px) {
    .page-title { font-size: 22px; }
    .page-head { align-items: stretch; }
    .page-actions { width: 100%; }
    .page-actions > .btn { flex: 1 1 auto; justify-content: center; }

    .btn { height: 44px; }
    .btn-sm { height: 40px; }
    .iconbtn { width: 44px; height: 44px; }
    .input, .select, .erp-search input { height: 44px; font-size: 16px; }
    .textarea { font-size: 16px; }
    .input-sm { height: 40px; }
    .pill { height: 40px; }
    .tab { padding: 10px 16px; }

    .card-pad { padding: 16px; }
    .card-head { padding: 12px 16px; }
    .acard, .level-card { padding: 16px; }
    .level-card { gap: 16px; }

    .filters { padding: 16px; gap: 12px; }
    .filters .field { min-width: 0; flex: 1 1 100%; }
    .filters .btn { flex: 1 1 100%; justify-content: center; }

    .t-scroll { overflow: visible; }
    .t-min { min-width: 0 !important; }
    .t-head { display: none; }
    .t-row {
        grid-template-columns: 1fr 1fr !important; gap: 10px 16px; padding: 14px 16px; align-items: start;
    }
    .t-row > * { min-width: 0; overflow-wrap: anywhere; }
    .t-row > :first-child { grid-column: 1 / -1; }
    .t-row > [data-label]:not(:first-child)::before {
        content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted);
        font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
    }
    .t-row > :last-child:not([data-label]):not(:first-child) {
        grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
        padding-top: 10px; border-top: 1px solid var(--line2);
    }
    .t-right { text-align: left; }

    /* Attendance buttons: one row of four equal columns. The script labels the cell "Holat" from the
       table head; that label would sit in the row next to "Keldi" and "Kechikdi", so it is hidden here. */
    .t-row > .seg:not(:first-child),
    .t-row > .seg:last-child:not([data-label]):not(:first-child) {
        grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; justify-content: stretch;
        padding-top: 10px; border-top: 1px solid var(--line2);
    }
    .t-row > .seg[data-label]:not(:first-child)::before { display: none; }
    .seg .pill { justify-content: center; padding: 0 2px; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

    .bar-row { grid-template-columns: 96px minmax(0, 1fr) 60px; gap: 8px; }
    .split { gap: 20px; }
    .sum-list { flex: 1 1 100%; }
    .chart { gap: 8px; }
    .due { text-align: left; }
    .kv { flex-wrap: wrap; gap: 4px 16px; }
}

@media (max-width: 340px) {
    .t-row > .seg:not(:first-child),
    .t-row > .seg:last-child:not([data-label]):not(:first-child) { grid-template-columns: 1fr 1fr; }
}

/* Phones */
@media (max-width: 480px) {
    .erp-topbar { padding: 8px 16px; gap: 10px; }
    .erp-topbar .select { max-width: 150px; }
    .erp-content { padding: 16px; gap: 16px; }
    .page-title { font-size: 20px; }

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi { padding: 14px; gap: 10px; }
    .kpi-value { font-size: 24px; }
    .achv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .form-grid { grid-template-columns: 1fr; }

    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .pager .btn { flex: 1 1 auto; justify-content: center; }

    .level-badge { width: 56px; height: 56px; font-size: 22px; }
    .profile-head { gap: 14px; }
    .avatar-lg { width: 56px; height: 56px; font-size: 20px; }
    .notif { padding: 14px 16px; }
    .auth-wrap { padding: 16px; }
    .auth-card { padding: 24px 20px; }
    .stu-row { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .erp-sidebar, .switch, .switch::after { transition: none; }
}

.switch.static { cursor: default; pointer-events: none; }

/* Forms: inline errors, file picker */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--err); }
.input.is-invalid:focus, .select.is-invalid:focus, .textarea.is-invalid:focus { box-shadow: 0 0 0 3px var(--err-bg); }
.file-input {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 5px 6px 5px 12px;
    border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.file-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.file-input.drag { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.file-input.picked .file-input-icon { color: var(--link); }
.file-input.is-invalid { border-color: var(--err); }
.file-input-icon { flex: 0 0 auto; color: var(--muted); }
.file-input-text {
    flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--muted); cursor: pointer;
}
.file-input-text b { color: var(--ink); font-weight: 500; }
.file-input-text small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.file-input-clear {
    flex: 0 0 auto; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.file-input-clear:hover { background: var(--neutral-bg); color: var(--ink); }
.file-input .btn { flex: 0 0 auto; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .pill { height: 28px; font-size: 12px; }
form[aria-busy="true"] button[type="submit"] { opacity: .6; cursor: progress; }
@media (max-width: 768px) { .presets .pill { height: 36px; } }

/* Student dashboard: groups and recent attendance */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.group-tile {
    display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line2);
    color: inherit; text-decoration: none; transition: background .15s;
}
.group-tile:last-child { border-bottom: 0; }
.group-tile:hover { background: var(--bg); }
.group-tile-badge {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 13px; letter-spacing: .02em;
}
.group-tile-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.group-tile-body b { font-weight: 500; }
.group-tile-body .card-sub { margin: 0; }
.group-tile-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: 13px; color: var(--ink2); }
.group-tile-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.group-tile-meta svg { color: var(--muted); }
.group-tile-arrow { flex: 0 0 auto; color: var(--muted); }

.att-strip { display: flex; gap: 6px; padding: 14px 20px 4px; }
.att-dot { flex: 1 1 0; max-width: 32px; height: 8px; border-radius: 999px; background: var(--line); }
.att-dot.ok { background: var(--ok); }
.att-dot.warn { background: #F59E0B; }
.att-dot.err { background: #EF4444; }
.att-dot.info { background: var(--accent); }
.att-item { display: flex; align-items: center; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--line2); }
.att-item:last-child { border-bottom: 0; }
.att-date {
    flex: 0 0 auto; width: 44px; display: flex; flex-direction: column; align-items: center; line-height: 1.1;
    padding: 6px 0; border-radius: 8px; background: var(--bg);
}
.att-date b { font-size: 16px; font-weight: 500; }
.att-date small { font-size: 11px; color: var(--muted); font-weight: 500; }
.att-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.att-body b { font-weight: 500; }
.att-body .card-sub { margin: 0; }
.att-status { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.att-status::before { content: ''; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.att-status.ok { color: var(--ok); }
.att-status.warn { color: var(--warn); }
.att-status.err { color: var(--err); }
.att-status.info { color: var(--accent-dark); }
.att-status.neutral { color: var(--neutral); }

@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) {
    .group-tile, .att-item { padding-left: 16px; padding-right: 16px; }
    .att-strip { padding-left: 16px; padding-right: 16px; }
    .group-tile-badge { width: 40px; height: 40px; }
}

/* Profile */
.profile-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 24px; }
.profile-avatar {
    width: 76px; height: 76px; font-size: 26px; font-weight: 500;
    box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--accent-soft);
}
.profile-who { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.profile-who h2 { margin: 0; font-size: 22px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.profile-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.profile-tags .card-sub { margin: 0; }
.profile-stats { display: flex; gap: 8px; }
.profile-stats > div {
    min-width: 86px; padding: 10px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line);
    display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.profile-stats b { font-size: 18px; font-weight: 500; line-height: 1.2; }
.profile-stats span { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.readonly-tag {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
    background: var(--neutral-bg); color: var(--neutral); font-size: 12px; font-weight: 500;
}
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info-item { display: flex; align-items: center; gap: 14px; padding: 16px 24px; border-bottom: 1px solid var(--line2); }
.info-grid .info-item:nth-child(odd) { border-right: 1px solid var(--line2); }
.info-icon {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center;
}
.info-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.info-text small { font-size: 12px; color: var(--muted); }
.info-text b { font-weight: 500; overflow-wrap: anywhere; }
.info-text b.muted { color: var(--muted); font-weight: 400; font-style: italic; }
.info-note {
    display: flex; align-items: flex-start; gap: 10px; margin: 16px 24px 20px; padding: 12px 14px; border-radius: 8px;
    background: var(--accent-soft); color: var(--accent-dark); font-size: 13px;
}
.info-note svg { flex: 0 0 auto; margin-top: 1px; }

@media (max-width: 768px) {
    .info-grid { grid-template-columns: 1fr; }
    .info-grid .info-item:nth-child(odd) { border-right: 0; }
    .info-item { padding: 14px 16px; }
    .info-note { margin: 14px 16px 16px; }
    .profile-hero { padding: 20px 16px; }
    .profile-stats { width: 100%; }
    .profile-stats > div { flex: 1 1 0; min-width: 0; }
}

/* BrainCoin and shop */
/* The BrainCoin coin: a gold minted disc with a sweeping shine; it flips when pointed at, the wallet coin floats */
.coin { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; perspective: 500px; }
.coin b { font-weight: 500; }
.coin-mark { position: relative; display: inline-block; width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%; overflow: hidden; vertical-align: middle; }
.coin-mark svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 1px 1.5px rgba(180, 83, 9, .35)); }
.coin-shine {
    position: absolute; inset: 0; border-radius: 50%; pointer-events: none; transform: translateX(-130%);
    background: linear-gradient(110deg, transparent 36%, rgba(255, 255, 255, .85) 50%, transparent 64%);
}
.coin:hover .coin-mark, .kpi:hover .coin-mark { animation: coin-flip .9s cubic-bezier(.4, .1, .2, 1); }
.coin:hover .coin-shine, .kpi:hover .coin-shine { animation: coin-shine 1.1s ease-in-out; }
.coin-lg .coin-mark { width: 22px; height: 22px; }
.coin-lg b { font-size: 16px; }
.coin-lg .coin-shine, .coin-xl .coin-shine, .kpi .coin-shine { animation: coin-shine 5s ease-in-out infinite; }
.coin-xl { gap: 12px; }
.coin-xl .coin-mark { width: 46px; height: 46px; animation: coin-pop .7s cubic-bezier(.2, 1.5, .4, 1) both, coin-float 3.8s ease-in-out .8s infinite; }
.coin-xl .coin-mark svg { filter: drop-shadow(0 4px 6px rgba(180, 83, 9, .35)); }
.coin-xl b { font-size: 36px; letter-spacing: -0.03em; line-height: 1; }
.kpi-icon .coin-mark { width: 22px; height: 22px; }
.kpi-icon:has(.coin-mark) { background: transparent; }
.coin-stat { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.coin-stat .coin-mark { width: 20px; height: 20px; }

@keyframes coin-shine { 0%, 60% { transform: translateX(-130%); } 85%, 100% { transform: translateX(130%); } }
@keyframes coin-flip { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
@keyframes coin-pop { from { transform: scale(.3) rotate(-25deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes coin-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes coin-twinkle { 0%, 100% { opacity: 0; transform: scale(.4); } 50% { opacity: .9; transform: scale(1); } }

.wallet {
    position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px;
    border-color: color-mix(in srgb, #F59E0B 38%, var(--line));
    background: radial-gradient(90% 170% at 0% 0%, color-mix(in srgb, #FCD34D 24%, transparent), transparent 62%), var(--surface);
}
.wallet::before, .wallet::after {
    content: ''; position: absolute; border-radius: 50%; background: #FCD34D; box-shadow: 0 0 10px 2px rgba(252, 211, 77, .7);
    opacity: 0; pointer-events: none; animation: coin-twinkle 3.4s ease-in-out infinite;
}
.wallet::before { width: 6px; height: 6px; left: 150px; top: 20px; }
.wallet::after { width: 4px; height: 4px; left: 78px; bottom: 18px; animation-delay: 1.5s; }
.wallet > * { position: relative; }
.wallet-main { display: flex; flex-direction: column; gap: 10px; }
.wallet-label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.wallet-stats { display: flex; gap: 8px; }
.wallet-stats > div {
    min-width: 120px; padding: 10px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 2px;
}
.wallet-stats b { font-size: 18px; font-weight: 500; }
.wallet-stats span { font-size: 12px; color: var(--muted); }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.shop-card { display: flex; flex-direction: column; overflow: hidden; }
.shop-media {
    position: relative; aspect-ratio: 4 / 3; background: var(--accent-soft); color: var(--link);
    display: flex; align-items: center; justify-content: center;
}
/* Photos come in any proportion; show each one whole inside the same 4:3 frame instead of cropping it. */
.shop-media img { width: 100%; height: 100%; object-fit: contain; }
.shop-stock {
    position: absolute; top: 10px; left: 10px; padding: 2px 8px; border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink2); font-size: 12px; font-weight: 500;
}
.shop-stock.out { background: var(--err-bg); color: var(--err); }
.shop-body { flex: 1 1 auto; padding: 14px 16px 4px; }
.shop-body h3 { margin: 0; font-size: 15px; font-weight: 500; }
.shop-body p {
    margin: 4px 0 0; color: var(--muted); font-size: 13px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.shop-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px 16px; min-height: 64px; }
.shop-missing { font-size: 12px; color: var(--muted); text-align: right; }
.shop-confirm { display: flex; gap: 6px; margin: 0; }

.order-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line2); }
.order-row:last-child { border-bottom: 0; }
.order-thumb {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--accent-soft);
    color: var(--link); display: flex; align-items: center; justify-content: center;
}
.order-thumb img { width: 100%; height: 100%; object-fit: cover; }
.order-body { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.order-body b { font-weight: 500; }
.order-body .card-sub { margin: 0; }
.order-cancel { margin: 0; }
.order-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.order-actions form { margin: 0; }
.order-cancel-form { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; width: 100%; }

@media (max-width: 768px) {
    .wallet { padding: 18px 16px; }
    .wallet-stats { width: 100%; }
    .wallet-stats > div { flex: 1 1 0; min-width: 0; }
    .order-row { padding: 14px 16px; }
    .order-actions { justify-content: flex-start; }
}
@media (max-width: 480px) {
    .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .shop-body { padding: 10px 12px 2px; }
    .shop-foot { flex-direction: column; align-items: stretch; padding: 10px 12px 12px; }
    .shop-foot .btn, .shop-confirm { width: 100%; justify-content: center; }
    .shop-confirm .btn { flex: 1 1 0; }
    .coin-xl b { font-size: 28px; }
}

/* Brand names keep their spelling inside uppercase labels and table headers. */
.brand-name { text-transform: none; letter-spacing: normal; }
@media (max-width: 768px) {
    .t-row > [data-label-keep-case]:not(:first-child)::before { text-transform: none; letter-spacing: normal; }
}

/* Date + 24-hour time pair */
.date-time { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px; }

/* Calendar (<x-date-input>) */
.datepicker { position: relative; }
.datepicker-trigger {
    display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; color: var(--ink);
}
.datepicker-trigger svg { flex: 0 0 auto; color: var(--muted); }
.datepicker-trigger .placeholder { color: var(--muted); }
.datepicker-pop {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; width: 296px; padding: 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(17, 24, 39, .14);
}
.datepicker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.datepicker-title { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.datepicker-year {
    height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
    font: 500 14px var(--font); color: var(--ink); cursor: pointer;
}
.datepicker-nav {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 6px; background: transparent; color: var(--ink2); cursor: pointer;
}
.datepicker-nav:hover { background: var(--bg); }
.datepicker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepicker-wd { padding: 6px 0; text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); }
.datepicker-wd:nth-child(n+6):nth-child(-n+7) { color: #EF4444; }
.datepicker-day {
    height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--ink);
    font: 500 13px var(--font); cursor: pointer;
}
.datepicker-day:hover:not(:disabled) { background: var(--accent-soft); }
.datepicker-day.out { color: var(--day-out); }
.datepicker-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.datepicker-day.on { background: var(--accent); color: #fff; font-weight: 500; }
.datepicker-day:disabled { color: var(--day-out); cursor: not-allowed; text-decoration: line-through; }
.datepicker-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line2); }
.datepicker-foot .link { border: 0; background: none; padding: 4px; cursor: pointer; font: 500 13px var(--font); }
.datepicker-foot .link:disabled { opacity: .4; cursor: not-allowed; }

@media (max-width: 480px) {
    .datepicker-pop { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto; border-radius: 14px 14px 0 0; padding: 16px 16px 24px; }
    .datepicker-day { height: 44px; font-size: 15px; }
}

/* Typography: one font everywhere, including form controls; even-width digits for figures */
.erp button, .erp input, .erp select, .erp textarea,
.auth-wrap button, .auth-wrap input, .auth-wrap select, .auth-wrap textarea { font-family: inherit; }
.erp, .auth-wrap { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.kpi-value, .coin b, .grade, .wallet-stats b, .profile-stats b, .att-date b, .t-row, .datepicker-day { font-variant-numeric: tabular-nums; }
.page-title { letter-spacing: -0.02em; }

/* Theme toggle and theme-dependent images */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
.auth-tools { position: fixed; top: 16px; right: 16px; z-index: 10; display: flex; gap: 8px; }
.logo-on-dark { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }
:root[data-theme="dark"] .logo-on-light { display: none !important; }
.erp-body, .erp-topbar, .card, .kpi, .btn, .input, .select, .textarea { transition: background-color .15s, border-color .15s, color .15s; }
:root[data-theme="dark"] .iconbtn .count { color: #2A0A0A; }

/* Language switcher */
.lang-switch { position: relative; }
.lang-btn { width: auto; padding: 0 12px; gap: 6px; font: 500 12px var(--font); color: var(--ink2); cursor: pointer; }
.lang-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 170px; padding: 6px;
    display: flex; flex-direction: column; gap: 2px; box-shadow: 0 12px 32px rgba(17, 24, 39, .14);
}
.lang-menu button {
    display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; border-radius: 6px;
    background: transparent; color: var(--ink2); font: 500 13px var(--font); text-align: left; cursor: pointer;
}
.lang-menu button b { width: 24px; font-weight: 500; color: var(--muted); }
.lang-menu button:hover { background: var(--hover); }
.lang-menu button.on { background: var(--accent-soft); color: var(--accent-dark); }

/* Pages without the app shell (login, password reset) keep readable text in both themes */
.auth-wrap { color: var(--ink); }
.auth-card label, .auth-card .field-hint { color: var(--ink2); }
:root[data-theme="dark"] .auth-card input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 1000px var(--surface) inset; }

/* Branch filter: our own dropdown instead of a native <select>, whose open list the browser colours by itself
   (it followed the device's theme, not the app's, and hid rows as white text on a white list). */
.branch-switch { position: relative; }
.branch-btn { max-width: 240px; padding: 0 12px; gap: 8px; font-weight: 500; color: var(--ink); }
.branch-btn span { overflow: hidden; text-overflow: ellipsis; }
.branch-btn svg:last-child { color: var(--muted); }
.branch-menu { min-width: 220px; max-height: 320px; overflow-y: auto; right: auto; left: 0; }
.branch-menu button { color: var(--ink); }
.branch-menu button .check-mark { margin-left: auto; visibility: hidden; color: var(--link); }
.branch-menu button.on .check-mark { visibility: visible; }
.branch-menu button.on { color: var(--ink); }
@media (max-width: 720px) { .branch-btn { max-width: 150px; } .branch-menu { min-width: 200px; } }

/* Minimal type: one light, even typeface; weight and size carry the hierarchy instead of heavy bold */
.erp, .auth-wrap { font-weight: 400; letter-spacing: -0.005em; }
.page-title, .auth-title { font-weight: 500; letter-spacing: -0.02em; }
.card-title { font-weight: 500; letter-spacing: -0.01em; }
.kpi-value { font-weight: 500; letter-spacing: -0.03em; }
.label-up, .t-head { font-weight: 500; letter-spacing: 0.04em; }
.btn, .badge, .pill, .tab { font-weight: 500; }
b, strong { font-weight: 500; }

/* Badges come alive: cards rise in one after another, earned medals shine and flip when pointed at, gold ones glow,
   badges from the last week pulse with a "New!" tag, a locked medal shakes its head. */
.achv { perspective: 600px; animation: achv-in .55s cubic-bezier(.2, 1.3, .4, 1) backwards; animation-delay: calc(var(--i, 0) * 70ms); transition: transform .2s ease, box-shadow .2s ease; }
.achv.earned:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(17, 24, 39, .12); }
.achv .ico { position: relative; overflow: hidden; }
.achv.earned .ico::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; transform: translateX(-140%);
    background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .75) 50%, transparent 65%);
    animation: achv-shine 4.8s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 400ms + 1s);
}
.achv.gold.earned .ico { animation: achv-glow 2.6s ease-in-out infinite; }
.achv.fresh .ico { animation: achv-pulse 1.8s ease-out infinite; }
.achv.earned:hover .ico { animation: achv-flip .9s cubic-bezier(.4, .1, .2, 1); }
.achv.locked:hover .ico { animation: achv-shake .45s ease-in-out; }
.achv-new {
    position: absolute; top: 10px; left: 10px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 600; letter-spacing: .04em; animation: achv-bounce 1.8s ease-in-out infinite;
}
.achv.fresh { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

@keyframes achv-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes achv-shine { 0%, 62% { transform: translateX(-140%); } 85%, 100% { transform: translateX(140%); } }
@keyframes achv-flip { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
@keyframes achv-glow {
    0%, 100% { box-shadow: inset 0 0 0 3px var(--medal-ring), 0 4px 10px rgba(17, 24, 39, .12), 0 0 0 0 rgba(247, 213, 107, 0); }
    50% { box-shadow: inset 0 0 0 3px var(--medal-ring), 0 4px 10px rgba(17, 24, 39, .12), 0 0 18px 4px rgba(247, 213, 107, .65); }
}
@keyframes achv-pulse {
    0% { box-shadow: inset 0 0 0 3px var(--medal-ring), 0 0 0 0 rgba(245, 158, 11, .55); }
    100% { box-shadow: inset 0 0 0 3px var(--medal-ring), 0 0 0 14px rgba(245, 158, 11, 0); }
}
@keyframes achv-shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 80% { transform: rotate(4deg); } }
@keyframes achv-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* "BrainCoin" inside text is shown as the coin itself (App\Support\CoinText, @coins) */
.coin-inline { display: inline-flex; vertical-align: -0.22em; margin: 0 .12em; perspective: 400px; }
.coin-inline .coin-mark { width: 1.15em; height: 1.15em; }
.coin-inline .coin-shine { animation: coin-shine 5s ease-in-out infinite; }
.coin-inline:hover .coin-mark { animation: coin-flip .9s cubic-bezier(.4, .1, .2, 1); }

/* Respect people who ask for less motion: the coin stays still */
@media (prefers-reduced-motion: reduce) {
    .coin-shine, .coin-mark, .wallet::before, .wallet::after, .achv, .achv .ico, .achv .ico::after, .achv-new { animation: none !important; }
    .coin:hover .coin-mark, .kpi:hover .coin-mark { animation: none; }
    .wallet::before, .wallet::after { display: none; }
}

/* <x-issued-credentials>: the login card is the only thing printed while it is on the page. */
.cred-secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; letter-spacing: .02em; }
@media print {
    body:has(.cred-card) * { visibility: hidden; }
    body:has(.cred-card) .cred-card, body:has(.cred-card) .cred-card * { visibility: visible; }
    .cred-card { position: absolute; top: 0; left: 0; width: 100%; border: 1px dashed #000; }
    .cred-card .cred-hide { display: none; }
}
