* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1d2733; --muted: #6b7a8c;
  --line: #e3e8ef; --brand: #1f6f5c; --brand-dark: #175446;
  --green-bg: #e3f4ec; --green-ink: #1b7a4c;
  --yellow-bg: #fdf3d8; --yellow-ink: #92700f;
  --red-bg: #fde5e3; --red-ink: #b3362a;
  --blue: #3d7bc4;
}
body { font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 28px; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 700; font-size: 20px; }
.brand-mark.big { width: 56px; height: 56px; font-size: 30px; border-radius: 14px; }
.brand-name { font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { padding: 7px 14px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { background: var(--bg); text-decoration: none; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; }
.sync { color: var(--muted); }
.user { font-weight: 600; }
.logout { color: var(--muted); }
.syncform { display: inline; }
.syncform button { padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--brand); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.syncform button:hover { background: var(--bg); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 24px; margin-bottom: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-date { font-size: 14px; color: var(--muted); font-weight: 400; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.kpi-num { font-size: 34px; font-weight: 700; }
.kpi-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi-good .kpi-num { color: var(--green-ink); }
.kpi-warn .kpi-num { color: var(--yellow-ink); }
.kpi-bad .kpi-num { color: var(--red-ink); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 20px; }
.card h2 { font-size: 16px; margin-bottom: 12px; }
.card h2 .muted { font-weight: 400; font-size: 13px; }
.mt { margin-top: 22px; }
.muted { color: var(--muted); }
.pad { padding: 12px 0; }
.nowrap { white-space: nowrap; }

.bars { width: 100%; border-collapse: collapse; }
.bars td { padding: 4px 6px; font-size: 13.5px; }
.bar-label { width: 160px; white-space: nowrap; }
.bar-label a { color: var(--ink); }
.bar-cell { width: auto; }
.bar { height: 16px; border-radius: 4px; min-width: 2px; }
.bar.green { background: #4cae82; }
.bar.yellow { background: #e6c14b; }
.bar.red { background: #dd6a5f; }
.bar.blue { background: var(--blue); }
.bar-num { width: 40px; text-align: right; font-weight: 600; }
.bar-pct { width: 55px; text-align: right; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dot.green { background: #4cae82; } .dot.yellow { background: #e6c14b; } .dot.red { background: #dd6a5f; }

.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mini th, .mini td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mini th { color: var(--muted); font-weight: 500; font-size: 12px; }
.mini .bad { color: var(--red-ink); font-weight: 600; }
.mini .good { color: var(--green-ink); font-weight: 600; }

.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data th { text-align: left; padding: 8px; color: var(--muted); font-weight: 500; font-size: 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.data td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tr:hover td { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green-ink); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow-ink); }
.pill.red { background: var(--red-bg); color: var(--red-ink); }
.pill.grey { background: #eceff3; color: var(--muted); }

.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; background: var(--yellow-bg); color: var(--yellow-ink); }
.flash.ok { background: var(--green-bg); color: var(--green-ink); }
.flash.bad { background: var(--red-bg); color: var(--red-ink); }

.editform label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.editform select, .editform input, .editform textarea { width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.editform button { padding: 10px 18px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.editform button:hover { background: var(--brand-dark); }

.timeline { list-style: none; font-size: 13px; }
.timeline li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.tl-date { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.tl-src { color: var(--muted); font-size: 11.5px; margin-left: 8px; background: var(--bg); border-radius: 6px; padding: 1px 7px; }

.statline { margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.statline strong { color: var(--ink); }

.trend { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.trend-bar { width: 100%; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px; }
.trend-num { font-size: 11px; color: var(--muted); order: -1; }
.trend-day { font-size: 11px; color: var(--muted); margin-top: 4px; }

.csv { font-size: 13px; font-weight: 500; margin-left: auto; }
.th-sort { color: var(--muted); }
.pager { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.pg { padding: 4px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.pg.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.rowedit { font-size: 12.5px; font-weight: 600; white-space: nowrap; padding: 3px 10px; border: 1px solid var(--line); border-radius: 7px; }
.rowedit:hover { background: var(--bg); text-decoration: none; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.filters input, .filters select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.filters button { padding: 9px 18px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.filters button:hover { background: var(--brand-dark); }
.filters .clear { font-size: 13px; }

.detail { width: 100%; border-collapse: collapse; }
.detail th { text-align: left; width: 220px; padding: 9px 10px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); vertical-align: top; }
.detail td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.back { font-size: 13px; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 40px 44px; width: 380px; text-align: center; box-shadow: 0 10px 30px rgba(20, 40, 60, .06); }
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input { width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.login-card button { width: 100%; padding: 11px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; margin-top: 6px; }
.login-card button:hover { background: var(--brand-dark); }
.login-error { background: var(--red-bg); color: var(--red-ink); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }

.datef { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.datef input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.upload-card form { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.upload-card input[type=file] { padding: 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--bg); }
.upload-card button { padding: 11px 18px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; align-self: flex-start; }
.upload-card button:hover { background: var(--brand-dark); }
.upload-notes { margin: 16px 0 0 18px; font-size: 13px; }
.upload-notes li { margin-bottom: 4px; }

.clearbtn { padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); background: #fff; white-space: nowrap; }
.clearbtn:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 14px; }
.chip { background: var(--green-bg); color: var(--brand-dark); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; }
.chip a { color: var(--brand-dark); margin-left: 6px; font-weight: 700; }
.chip a:hover { color: var(--red-ink); text-decoration: none; }
