:root {
  --bg: #f4f7fb; --card: #fff; --ink: #1f2a37; --muted: #6b7280; --line: #e5e7eb;
  --teal: #14b8a6; --teal-d: #0f766e; --red: #ef4444; --amber: #f59e0b; --green: #22c55e;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
a { color: var(--teal-d); }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }

.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
       background: linear-gradient(90deg, #0f766e, #14b8a6); color: #fff; padding: 10px 16px; }
.top a { color: #fff; text-decoration: none; margin-right: 14px; font-weight: 600; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.3rem; }
.brand img { width: 34px; height: 34px; }
.top nav { display: flex; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
button.link { background: none; border: 0; color: #fff; font-weight: 600; cursor: pointer; padding: 0; font-size: 1rem; }

.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.highlight { border: 2px solid var(--teal); }
.card.alarm { border: 2px solid var(--red); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.grid .card { margin-bottom: 0; }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 8px 0; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: .95rem; }
label.check { flex-direction: row !important; align-items: center; gap: 6px; }
.links a { margin-right: 14px; }

input, select, textarea, button { font: inherit; }
input, select, textarea { border: 1px solid #cbd5e1; border-radius: 8px; padding: 6px 8px; background: #fff; }
input.num { width: 76px; }
textarea { width: 100%; }
.code-edit { font-family: Consolas, "Cascadia Mono", monospace; font-size: .92rem; line-height: 1.4; }
button { border: 1px solid #cbd5e1; background: #f8fafc; border-radius: 9px; padding: 7px 12px; cursor: pointer; }
button:hover { background: #eef2f7; }
button.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--teal-d); }
button.good { background: #dcfce7; border-color: #86efac; font-weight: 600; }
button.bad { background: #fee2e2; border-color: #fca5a5; }
button.big { padding: 12px 22px; font-size: 1.05rem; }
.sticky { position: sticky; bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.actions form { margin: 0; }
.balance { font-size: 1.5rem; font-weight: 700; padding: 10px 14px; border-radius: 12px; background: #ccfbf1; margin: 6px 0; }
.balance.low { background: #fef3c7; }
.pill { font-size: .8rem; padding: 3px 9px; border-radius: 99px; background: #e5e7eb; white-space: nowrap; }
.pill.ok { background: #dcfce7; color: #166534; }
.code { font-family: Consolas, monospace; font-size: 2rem; letter-spacing: .2em; color: var(--teal-d); }
.code.small { font-size: 1rem; letter-spacing: .1em; }
.chip { display: inline-block; padding: 6px 12px; border-radius: 99px; background: #eef2f7; text-decoration: none; }
.chip.add { background: #ccfbf1; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.flash.ok { background: #dcfce7; }
.flash.bad { background: #fee2e2; }
.flash.warn { background: #fef3c7; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; }
tr.bad td { background: #fff5f5; }
table.words input:not([type=checkbox]):not(.num) { width: 100%; min-width: 90px; }
tr.new input { background: #f8fffe; }
.windows .day { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; }
ul.cols { columns: 2; }

.chart { width: 100%; height: 200px; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .used { fill: #fb923c; }
.chart .earned { fill: var(--teal); }
.chart .acc { fill: #60a5fa; }
.legend { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin: 0 4px 0 10px; }
.sw.used { background: #fb923c; } .sw.earned { background: var(--teal); }

@media (max-width: 640px) {
  main { padding: 10px; }
  table.lessons th:nth-child(n+3), table.lessons td:nth-child(n+3) { padding: 3px 2px; }
  input.num { width: 58px; }
  ul.cols { columns: 1; }
}
