:root {
    --green: #0e5c43;
    --green-2: #187454;
    --ink: #1b2a24;
    --muted: #5d6f67;
    --paper: #f4f7f5;
    --card: #ffffff;
    --line: #d5e3db;
    --warn: #9a3412;
    --warn-bg: #fff7ed;
    --ok: #166534;
    --ok-bg: #f0fdf4;
    --info: #1e40af;
    --info-bg: #eff6ff;
    --danger: #b42318;
    --shadow: 0 12px 40px rgba(20, 48, 36, 0.08);
    --radius: 16px;
    font-family: "Segoe UI", "Be Vietnam Pro", sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.eyebrow { color: var(--green); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.lead { color: var(--muted); line-height: 1.5; }

.login-wrap, .gate {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(circle at top left, rgba(24, 116, 84, 0.16), transparent 42%),
        var(--paper);
}
.gate { position: fixed; inset: 0; z-index: 30; background: rgba(16, 32, 26, 0.45); }
.login-card {
    width: min(440px, 100%);
    background: var(--card);
    border-radius: 24px;
    padding: 28px 24px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 14px;
}
.login-card h1, .login-card h2 { font-size: 1.7rem; line-height: 1.2; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 500;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(24, 116, 84, 0.2); border-color: var(--green-2); }
.btn {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 700;
    background: #e7f2ec;
    color: var(--green);
}
.btn.primary { background: var(--green); color: white; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.warn { background: var(--warn-bg); color: var(--warn); }
.btn.ok { background: var(--ok); color: white; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.form-error { color: var(--danger); min-height: 1.2em; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

.app { width: min(1120px, calc(100% - 24px)); margin: 0 auto; padding: 16px 0 40px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 8px 0 14px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.tabs button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 14px;
    white-space: nowrap;
    font-weight: 700;
}
.tabs button.is-on { background: white; color: var(--green); border-color: var(--line); }
.panel { display: grid; gap: 14px; }
.card, .stats, .table-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card { padding: 16px; display: grid; gap: 12px; }
.card header, .split, .actions, .person { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.card h3 { font-size: 1.12rem; }
.content { white-space: pre-wrap; line-height: 1.5; }
.meta { color: var(--muted); font-size: 0.92rem; }
.badge { border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; font-weight: 800; background: #eef2f0; }
.badge.todo { background: #eef2ff; color: var(--info); }
.badge.doing { background: #ecfeff; color: #155e75; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge.revise, .badge.overdue { background: #fef2f2; color: var(--danger); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); overflow: hidden; }
.stats div { background: white; padding: 14px; }
.stats strong { display: block; font-size: 1.4rem; color: var(--green); }
.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; }
.stack { display: grid; gap: 10px; }
.people, .checks { display: grid; gap: 6px; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.people label, .checks label { font-weight: 600; grid-template-columns: auto 1fr; align-items: center; }
.files { margin: 0; padding-left: 18px; }
.files a { color: var(--green); font-weight: 700; }
.shot { max-width: min(100%, 360px); border-radius: 12px; border: 1px solid var(--line); }
.progress { height: 8px; background: #e5eeea; border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--green-2); }
.callout { background: var(--warn-bg); border-radius: 12px; padding: 10px 12px; color: var(--warn); }
.callout.ok { background: var(--ok-bg); color: var(--ok); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.92rem; }
th { background: #f7fbf8; position: sticky; top: 0; }
.search { max-width: 360px; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    background: var(--ink);
    color: white;
    padding: 10px 14px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 40;
    max-width: calc(100% - 24px);
}
.toast.show { opacity: 1; }
.import-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.import-bar .file-btn { position: relative; display: inline-flex; align-items: center; width: auto; }
.import-bar .file-btn input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    padding: 0;
    border: 0;
}
.import-modal {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background: rgba(16, 32, 26, 0.45);
}
.import-card { width: min(560px, 100%); }
.import-errors { margin: 0; padding-left: 18px; color: var(--danger); display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.btn.danger { background: var(--danger); color: white; }
.badge.party { background: #b42318; color: white; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 4px; }
.stat-card span { color: var(--muted); font-size: 0.88rem; font-weight: 700; }
.stat-card strong { font-size: 1.6rem; }
.chart-grid { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 14px; }
.donut-wrap { display: grid; grid-template-columns: 168px 1fr; gap: 12px; align-items: center; }
.donut { width: 100%; height: auto; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 99px; margin-right: 6px; }
.bar-chart { width: 100%; height: auto; }
.board-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.board-tools .search, .board-tools label { width: min(280px, 100%); }
.person-progress { display: grid; gap: 4px; min-width: 150px; }
.person-progress small { color: var(--muted); }
.progress span.grade-best { background: #166534; }
.progress span.grade-good { background: #187454; }
.progress span.grade-ok { background: #1d4ed8; }
.progress span.grade-low { background: #b42318; }

@media (max-width: 800px) {
    .stats, .grid-2, .stat-grid, .chart-grid, .donut-wrap { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; }
    .login-card h1 { font-size: 1.45rem; }
}
