/* BMS template stylesheet.
   Copyright (c) Tom Choi. All rights reserved.
   Written from scratch for the Basic Management System. No third-party code. */

/* ---------- 1. Tokens ---------- */
:root {
  --green: #7ab55c;
  --green-dark: #5f9844;
  --green-pale: #eef6e9;
  --ink: #333333;
  --text: #6f6f6f;
  --muted: #9a9a9a;
  --line: #e4e4e4;
  --panel: #f7f7f7;
  --white: #ffffff;
  --red: #c9523f;
  --red-pale: #fbeeeb;
  --amber: #c98f2b;
  --amber-pale: #fbf4e6;
  --blue: #4a86b8;
  --blue-pale: #ecf3f9;
  --side-w: 270px;
  --gap: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--green);
}
h1, h2, h3, h4 { color: var(--ink); font-weight: 300; line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; font-weight: 400; }
h4 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--green-dark); font-weight: 700; text-decoration: none; }
a:hover, a:focus { color: var(--ink); text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
small, .small { font-size: .85rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--panel); padding: 1px 5px; }
img, svg { max-width: 100%; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.125em; }
.icon-lg { width: 1.5em; height: 1.5em; }

/* ---------- 3. Page layout: fixed sidebar + content ---------- */
.side {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--side-w);
  padding: 0 var(--gap) var(--gap);
  overflow-y: auto;
  color: var(--white);
}
.brand { display: block; padding: 34px 6px 26px; color: var(--white); font-size: 2rem; font-weight: 700;
  line-height: 1; letter-spacing: -.5px; }
.brand span { font-weight: 300; opacity: .85; }
.brand:hover, .brand:focus { color: var(--white); text-decoration: none; }
.side-top { display: none; }

.nav { list-style: none; margin: 0; padding: 0; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 400; text-align: left; color: var(--white);
  border-bottom: 1px solid rgba(255, 255, 255, .25);
}
.nav a:hover, .nav a:focus, .nav button:hover, .nav button:focus {
  background: rgba(0, 0, 0, .12); color: var(--white); text-decoration: none; }
.nav .is-active > a { background: var(--ink); border-bottom-color: var(--ink); font-weight: 700; }
.nav .nav { display: none; background: rgba(0, 0, 0, .08); }
.nav .is-open > .nav { display: block; }
.nav .nav a { padding-left: 38px; font-size: .95rem; }
.nav .caret { margin-left: auto; transition: transform .15s; }
.nav .is-open > button .caret { transform: rotate(90deg); }
.side-note { margin: 22px 6px 0; font-size: .85rem; color: rgba(255, 255, 255, .85); line-height: 1.5; }
.side-note strong { display: block; font-size: 1.05rem; color: var(--white); }

.main { margin-left: var(--side-w); min-height: 100vh; background: var(--white); display: flex; flex-direction: column; }
.main-body { flex: 1; padding: 28px 32px 40px; max-width: 1180px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 12px; padding-bottom: 14px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.foot { background: var(--panel); border-top: 1px solid var(--line); padding: 18px 32px; font-size: .9rem;
  color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

/* One-column page (login): no sidebar */
.solo { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.solo-box { width: 100%; max-width: 400px; background: var(--white); padding: 32px; }
.solo-box .brand { color: var(--green-dark); padding: 0 0 20px; }
.solo-box .brand span { color: var(--ink); opacity: 1; }

/* ---------- 4. Grid ---------- */
.row { display: grid; gap: 24px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: 24px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
.stack > * + * { margin-top: 16px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- 5. Panels (cards) ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); padding: 20px; }
.panel-plain { background: var(--white); }
.panel-accent { border-top: 3px solid var(--green); }
.panel > :last-child { margin-bottom: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-title h2, .panel-title h3 { margin: 0; }
.stat { font-size: 2.4rem; font-weight: 300; color: var(--ink); line-height: 1.1; }
.stat small { font-size: 1rem; color: var(--muted); }
.banner { background: var(--ink); color: var(--white); padding: 22px 24px; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.banner h2 { color: var(--white); margin: 0; }
.banner p { margin: 0; color: rgba(255, 255, 255, .8); }

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 18px; border: 1px solid var(--green); background: var(--green); color: var(--white);
  font: inherit; font-weight: 700; line-height: 1.4; cursor: pointer; text-decoration: none;
}
.btn:hover, .btn:focus { background: var(--green-dark); border-color: var(--green-dark); color: var(--white); text-decoration: none; }
.btn-dark { background: var(--ink); border-color: var(--ink); }
.btn-dark:hover, .btn-dark:focus { background: #000; border-color: #000; }
.btn-line { background: transparent; color: var(--ink); border-color: #bdbdbd; }
.btn-line:hover, .btn-line:focus { background: var(--panel); color: var(--ink); border-color: var(--ink); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover, .btn-danger:focus { background: #a84131; border-color: #a84131; }
.btn-sm { padding: 3px 10px; font-size: .85rem; }
.btn-lg { padding: 12px 26px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 4px 8px; border-color: transparent; background: transparent; color: var(--muted); }
.btn-icon:hover, .btn-icon:focus { background: var(--line); border-color: var(--line); color: var(--ink); }

/* ---------- 7. Forms ---------- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 700; font-size: .95rem; }
.input, .select, .textarea {
  display: block; width: 100%; padding: 8px 12px; border: 1px solid #c9c9c9; border-radius: 0;
  background: var(--white); color: var(--ink); font: inherit; line-height: 1.5;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--green-dark); box-shadow: 0 0 0 2px var(--green-pale); }
.input-sm { width: auto; max-width: 140px; }
.hint { margin-top: 4px; font-size: .85rem; color: var(--muted); }
.field-error .input, .field-error .select, .field-error .textarea { border-color: var(--red); }
.field-error .hint { color: var(--red); }
.check { display: flex; align-items: flex-start; gap: 8px; }
.check input { width: 18px; height: 18px; margin-top: 5px; accent-color: var(--green-dark); }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.form-row .field { margin-bottom: 0; flex: 1 1 160px; }
.choice { display: inline-flex; border: 1px solid #c9c9c9; }
.choice label { padding: 6px 14px; cursor: pointer; border-right: 1px solid #c9c9c9; font-weight: 400; color: var(--ink); }
.choice label:last-of-type { border-right: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice input:checked + label { background: var(--ink); color: var(--white); }
.choice input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }
.choice input:disabled + label { opacity: .5; cursor: not-allowed; }

/* ---------- 8. Messages, tags ---------- */
.note { padding: 12px 16px; border-left: 4px solid var(--green); background: var(--green-pale); color: var(--ink); margin-bottom: 16px; }
.note-info { border-color: var(--blue); background: var(--blue-pale); }
.note-warn { border-color: var(--amber); background: var(--amber-pale); }
.note-bad { border-color: var(--red); background: var(--red-pale); }
.tag { display: inline-block; padding: 1px 9px; font-size: .78rem; font-weight: 700; line-height: 1.6;
  background: var(--line); color: var(--ink); white-space: nowrap; }
.tag-green { background: var(--green); color: var(--white); }
.tag-dark { background: var(--ink); color: var(--white); }
.tag-amber { background: var(--amber); color: var(--white); }
.tag-red { background: var(--red); color: var(--white); }
.tag-blue { background: var(--blue); color: var(--white); }
.tag-line { background: transparent; border: 1px solid #bdbdbd; color: var(--text); }

/* ---------- 9. Tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; list-style: none; margin: 0 0 20px; padding: 0; border-bottom: 2px solid var(--ink); }
.tabs a { display: block; padding: 7px 18px; background: var(--panel); color: var(--text); font-weight: 400; }
.tabs a:hover, .tabs a:focus { background: var(--line); color: var(--ink); text-decoration: none; }
.tabs .is-active a { background: var(--ink); color: var(--white); font-weight: 700; }

/* ---------- 10. Lists, task tree ---------- */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--white); }
.list > li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { color: var(--ink); font-weight: 700; display: block; }
.list .meta { font-size: .85rem; color: var(--muted); }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 26px; border-left: 2px solid var(--line); }
.tree .task { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.tree .task:hover { background: var(--panel); }
.tree .task input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green-dark); flex: none; }
.tree .task .name { flex: 1; min-width: 0; color: var(--ink); }
.tree .is-done > .task .name { color: var(--muted); text-decoration: line-through; }
.tree .tools { display: flex; gap: 2px; opacity: .55; }
.tree .task:hover .tools, .tree .task:focus-within .tools { opacity: 1; }

/* ---------- 11. Progress, ring, glass ---------- */
.bar { height: 14px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--green); }
.bar-over > span { background: var(--amber); }
.bar-sm { height: 6px; }
.w-0 { width: 0 !important; } .w-10 { width: 10% !important; } .w-20 { width: 20% !important; }
.w-30 { width: 30% !important; } .w-40 { width: 40% !important; } .w-50 { width: 50% !important; }
.w-60 { width: 60% !important; } .w-70 { width: 70% !important; } .w-80 { width: 80% !important; }
.w-90 { width: 90% !important; } .w-100 { width: 100% !important; }

.ring { width: 120px; height: 120px; }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--line); }
.ring .value { stroke: var(--green); stroke-linecap: butt; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring text { font-size: 22px; font-weight: 300; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }

.glass { position: relative; width: 100px; height: 150px; margin: 0 auto; border: 3px solid var(--ink); border-top: 0;
  background: var(--white); overflow: hidden; }
.glass .water { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: #8fc3e6; transition: height .6s ease; }
.glass.is-full .water { height: 82%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 10px; border: 1px solid var(--green); background: var(--green-pale); color: var(--ink);
  font: inherit; font-size: .85rem; cursor: pointer; }
.chip:hover, .chip:focus { background: var(--red-pale); border-color: var(--red); }
.chip-over { border-color: var(--amber); background: var(--amber-pale); }

/* ---------- 12. Tables, schedule, week grid, calendar ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--ink); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--ink); }
.table tbody tr:hover { background: var(--panel); }

.blocks { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.block { border: 1px solid var(--line); border-top: 4px solid var(--line); padding: 16px; background: var(--white); }
.block h3 { margin-bottom: 2px; }
.block .time { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.block.is-now { border-top-color: var(--green); background: var(--green-pale); }
.block.is-off { opacity: .45; }

.week { display: grid; gap: 8px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day { border: 1px solid var(--line); padding: 10px; min-height: 96px; background: var(--white); font-size: .9rem; }
.day .d { display: block; color: var(--ink); font-weight: 700; }
.day.is-today { border-color: var(--green); border-width: 2px; }
.day.is-rest { background: var(--panel); color: var(--muted); }
.day.is-blank { border-color: transparent; background: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.dot-blue { background: var(--blue); }

/* ---------- 13. Small screens ---------- */
@media (max-width: 860px) {
  .side { position: static; width: auto; padding: 0; overflow: visible; }
  .side-top { display: flex; align-items: center; justify-content: space-between; padding: 10px var(--gap); }
  .side-top .brand { padding: 0; font-size: 1.5rem; }
  .side > .brand { display: none; }
  .menu-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .7);
    background: transparent; color: var(--white); font: inherit; cursor: pointer; }
  .side-menu { display: none; padding: 0 var(--gap) var(--gap); }
  .side.is-open .side-menu { display: block; }
  .main { margin-left: 0; }
  .main-body { padding: 20px var(--gap) 32px; }
  .foot { padding: 16px var(--gap); }
  .row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .row > [class^="col-"] { grid-column: auto; }
  .blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  h1 { font-size: 1.7rem; }
  .tree ul { margin-left: 14px; }
}
@media (max-width: 480px) {
  .blocks { grid-template-columns: minmax(0, 1fr); }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  body { background: #fff; }
  .side, .foot, .actions, .tools { display: none !important; }
  .main { margin: 0; }
}

/* ---------- 14. Additions for the BMS application (same style, original code) ---------- */
.nav form { margin: 0; }
.qr { display: block; width: 200px; height: 200px; margin: 0 0 12px; background: var(--white); border: 1px solid var(--line); }
.qr path { fill: var(--ink); }
details.more > summary { list-style: none; display: inline-flex; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] { flex-basis: 100%; }
details.more > form { margin-top: 10px; padding: 12px; background: var(--panel); border: 1px solid var(--line); max-width: 360px; }
.table-wrap { margin-bottom: 24px; }
.table .nowrap { white-space: nowrap; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.form-narrow { max-width: 640px; }
.page-head .actions form, .tree .tools form, .tree .task form { margin: 0; }
.list .bar { display: block; margin: 6px 0 2px; max-width: 320px; }
.list a.title:hover { color: var(--green-dark); }
.tick { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px; padding: 0;
  border: 2px solid #9a9a9a; background: var(--white); color: transparent; font-size: 14px; cursor: pointer; }
button.tick:hover, button.tick:focus { border-color: var(--green-dark); }
.tick.is-on { background: var(--green-dark); border-color: var(--green-dark); color: var(--white); }
span.tick { cursor: default; }
.tree .task .name { overflow-wrap: anywhere; }
.tree .task .name .notes, .tree .task .name .meta { display: block; font-size: .85rem; color: var(--muted); white-space: pre-line; }
.tree .task .name .tag { margin-left: 6px; }
.tree li:target > .task { background: var(--green-pale); }
.task-more { margin: 0 0 0 42px; font-size: .85rem; }
.task-more > summary { cursor: pointer; color: var(--muted); padding: 2px 0 6px; list-style: none; }
.task-more > summary::-webkit-details-marker { display: none; }
.task-more > summary:hover, .task-more[open] > summary { color: var(--ink); }
.task-forms { padding: 12px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 1rem; }
.task-forms > form + form, .task-forms > p { margin-top: 12px; }
.textarea-sm { min-height: 64px; }
.add-task { margin-top: 20px; }
a.tag:hover, a.tag:focus { text-decoration: none; color: var(--ink); background: var(--line); }
a.tag.tag-dark:hover, a.tag.tag-dark:focus { background: var(--ink); color: var(--white); }
@media (max-width: 860px) { .task-more { margin-left: 14px; } }
.center-row { justify-content: center; margin-bottom: 12px; }
.cluster form, .chips form, .day form { margin: 0; }
.glass-state { margin: 12px 0; color: var(--ink); }
.glass-size { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.glass-size .choice { margin-bottom: 10px; }
.left { text-align: left; }
.ring .value { transition: stroke-dasharray .4s ease; }
.day .workout { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 6px; font-size: .85rem; overflow-wrap: anywhere; }
.entry { display: flex; align-items: flex-end; gap: 8px; }
.entry > form:first-child { flex: 1; }
.entry-delete { margin-top: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; }
.cal { display: grid; gap: 4px; grid-template-columns: repeat(7, minmax(0, 1fr)); margin-bottom: 12px; }
.cal-name { font-size: .78rem; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .04em; text-align: center; }
.cal .day { min-height: 64px; padding: 6px 8px; font-weight: 400; color: var(--text); }
.cal a.day:hover, .cal a.day:focus { background: var(--green-pale); text-decoration: none; }
@media (max-width: 480px) { .cal .day { min-height: 52px; padding: 4px; } .cal .dot { width: 6px; height: 6px; } }
