*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #f4f5f7;
    --surface:   #ffffff;
    --primary:   #4f6ef7;
    --primary-d: #3a57e8;
    --danger:    #e53e3e;
    --success:   #38a169;
    --text:      #1a202c;
    --muted:     #718096;
    --border:    #e2e8f0;
    --radius:    8px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-rows: 56px 1fr;
    min-height: 100vh;
}

nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

nav .brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; }

nav a {
    font-size: .9rem;
    color: var(--muted);
    padding: .25rem 0;
    border-bottom: 2px solid transparent;
}
nav a.active, nav a:hover { color: var(--primary); border-bottom-color: var(--primary); }

nav .nav-user { font-size: .85rem; color: var(--muted); }

.main { padding: 1.5rem; max-width: 900px; margin: 0 auto; width: 100%; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header h2 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-d); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { opacity: .85; }
.btn-ghost    { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover    { background: var(--bg); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .9rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: .6rem .75rem; background: var(--bg); font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-green  { background: #c6f6d5; color: #276749; }
.badge-red    { background: #fed7d7; color: #9b2c2c; }
.badge-blue   { background: #bee3f8; color: #2a6496; }
.badge-yellow { background: #fefcbf; color: #744210; }
.badge-gray   { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-sm    { font-size: .85rem; }
.mt-1 { margin-top: .5rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.done-row td { opacity: .55; text-decoration: line-through; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #2d3748;
    color: #fff;
    padding: .75rem 1.25rem;
    border-radius: 8px;
    font-size: .875rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    z-index: 999;
}
#toast.show { opacity: 1; pointer-events: auto; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    padding: 1.5rem;
    width: min(480px, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}
.modal h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    width: min(380px, calc(100vw - 2rem));
}
.login-box h1 { font-size: 1.25rem; margin-bottom: 1.5rem; text-align: center; }
.login-error  { color: var(--danger); font-size: .875rem; margin-bottom: .75rem; }
