:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #e2e6ea;
    --text: #1d2430;
    --muted: #6b7684;
    --accent: #0a6b4f;
    --accent-soft: #e6f2ee;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --warning: #8a5a00;
    --warning-soft: #fdf3e0;
    --ok: #17663f;
    --ok-soft: #e6f4ec;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    padding: 4px 7px;
    font-size: 12px;
    letter-spacing: .04em;
}

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }

.nav a {
    color: var(--muted);
    padding: 7px 12px;
    border-radius: 7px;
    font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.locale-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}
.locale-toggle a {
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.locale-toggle a:hover { background: var(--bg); text-decoration: none; }
.locale-toggle a.active { background: var(--accent); color: #fff; }

.logout { color: var(--muted); font-size: 14px; }

/* ---------- layout ---------- */

.content { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

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

/* ---------- stat tiles ---------- */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 600; margin-top: 4px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); }
.stat.danger .value { color: var(--danger); }
.stat.warning .value { color: var(--warning); }
.stat.ok .value { color: var(--ok); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--border);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.table-wrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.empty { color: var(--muted); padding: 22px; text-align: center; }

/* ---------- pills ---------- */

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-muted { background: #eef1f4; color: var(--muted); }

/* ---------- forms and buttons ---------- */

input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], select {
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- edit forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid .field input { width: 100%; }
.form-grid .field-wide { grid-column: 1 / -1; }
.form-grid .hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--danger); font-weight: 600; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- flash ---------- */

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: #c9e6d5; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f3cbc7; }

/* ---------- timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; background: var(--muted); }
.timeline .dot.purchase { background: #2d6ecb; }
.timeline .dot.lesson { background: var(--accent); }
.timeline .dot.certificate { background: #8a5a00; }
.timeline .when { color: var(--muted); font-size: 13px; width: 130px; flex: 0 0 auto; }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px; }
.login-card h1 { margin-bottom: 20px; font-size: 19px; }
.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* ---------- misc ---------- */

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.notice { background: var(--warning-soft); color: var(--warning); padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14181d;
        --surface: #1b2026;
        --border: #2a313a;
        --text: #e7ebf0;
        --muted: #97a3b2;
        --accent: #4bbd93;
        --accent-soft: #1d3a32;
        --danger: #ff8a80;
        --danger-soft: #3a2422;
        --warning: #f0c070;
        --warning-soft: #3a3020;
        --ok: #7bd7a8;
        --ok-soft: #1d3a2b;
    }
    tbody tr:hover { background: #20262d; }
    .pill-muted { background: #262d35; }
}
