:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2e0da;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --error: #b3261e;
  --error-bg: #fbeceb;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --ok-bg: #e6f2ec;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
small, .muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 1.25rem; padding: .7rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: .02em; }
.topbar nav { display: flex; gap: 1rem; margin-left: auto; align-items: center; }
.topbar nav a { text-decoration: none; color: var(--text); }
.topbar form { margin: 0; }
.linkbutton { background: none; border: none; color: var(--text); cursor: pointer; font: inherit; padding: 0; }

main { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
main.wide { max-width: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.product h2 { margin-top: 0; }

.btn { display: inline-block; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: .5rem 1rem; font: inherit; cursor: pointer; text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.small { padding: .2rem .6rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; margin: .6rem 0 .2rem; font-weight: 500; }
input, select, textarea { font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px;
  width: 100%; background: #fff; color: var(--text); }
input[type=checkbox] { width: auto; }
textarea { min-height: 5rem; font-family: ui-monospace, monospace; font-size: .85rem; }
form.narrow { max-width: 420px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .85rem; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; }
.table-scroll { overflow-x: auto; }

.filterbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 0 0 1rem; }
.filterbar input[type=search] { width: 18rem; max-width: 100%; }
.filterbar .btn.small { padding: .35rem 1rem; }
.info { position: relative; }
.info summary { list-style: none; cursor: pointer; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: 1px solid var(--accent); color: var(--accent); display: grid; place-items: center;
  font: italic 700 .85rem/1 Georgia, serif; user-select: none; }
.info summary::-webkit-details-marker { display: none; }
.info[open] summary { background: var(--accent); color: var(--accent-text); }
.info-pop { position: absolute; z-index: 10; top: calc(100% + .4rem); left: 0; width: max-content; max-width: 20rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .1); font-size: .85rem; }
.info-pop p { margin: .3rem 0 0; }
.admin-table th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
.admin-table tr.filter-row td { padding: .25rem .3rem; background: var(--bg); }
.admin-table tr.filter-row input, .admin-table tr.filter-row select { min-width: 6rem; padding: .2rem .3rem;
  font-size: .85rem; }
.admin-table tr.filter-row .active { border-color: var(--accent); background: var(--ok-bg); }

.notice { padding: .6rem .8rem; border-radius: 6px; margin: .5rem 0; }
.notice.error { background: var(--error-bg); color: var(--error); }
.notice.warning { background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--line); }
.badge.paid, .badge.done, .badge.issued { background: var(--ok-bg); }
.badge.expired, .badge.cancelled, .badge.failed { background: var(--error-bg); color: var(--error); }

/* ---------------------------------------------------------------- designer */
.designer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 52px); }
.designer .viewport { position: relative; min-height: 300px; background: #ecebe7; }
.designer .viewport canvas { display: block; width: 100%; height: 100%; }
.viewport .hint { position: absolute; left: .75rem; bottom: .5rem; font-size: .8rem; color: var(--muted); }
.designer .panel { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 1rem; }
.tabs { display: flex; gap: .25rem; margin-bottom: .75rem; }
.tabs button { flex: 1; padding: .45rem; border: 1px solid var(--line); background: var(--bg); border-radius: 6px;
  cursor: pointer; font: inherit; }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.param { margin-bottom: .6rem; }
.param .head { display: flex; justify-content: space-between; }
.param input[type=range] { padding: 0; }
.param input[type=number] { width: 6.5rem; padding: .15rem .35rem; text-align: right; }
.partlist button { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: 6px; padding: .35rem .5rem; margin-bottom: .25rem; cursor: pointer; font: inherit; }
.partlist button.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.conn { border-bottom: 1px solid var(--line); padding: .4rem 0; }
.conn select { margin-top: .2rem; }
.pricebox { position: sticky; bottom: -1rem; background: var(--surface); border-top: 1px solid var(--line);
  margin: 1rem -1rem -1rem; padding: .75rem 1rem 1rem; }
.pricebox .total { font-size: 1.5rem; font-weight: 700; }
.pricebox details { margin: .4rem 0; font-size: .9rem; }
.faces { display: flex; flex-wrap: wrap; gap: .5rem; }
.faces label { display: flex; align-items: center; gap: .25rem; margin: 0; font-weight: 400; }
.busy { opacity: .6; pointer-events: none; }

/* ---------------------------------------------------------------- admin */
.admin { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.25rem; }
.admin aside { font-size: .9rem; }
.admin aside h4 { margin: .9rem 0 .2rem; font-size: .8rem; text-transform: uppercase; color: var(--muted); }
.admin aside a { display: block; text-decoration: none; padding: .1rem 0; }
.admin aside a.current { font-weight: 700; }
td.cell { font-size: .85rem; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.heat { border-collapse: separate; border-spacing: 2px; font-size: .75rem; }
.heat th, .heat td { padding: 2px 4px; border: none; text-align: center; }
.heat td.name { text-align: left; white-space: nowrap; }
.heat td.day { min-width: 2.2rem; border-radius: 3px; }
.heat td.closed { background: repeating-linear-gradient(45deg, #ddd, #ddd 3px, #eee 3px, #eee 6px); color: var(--muted); }
.heat th.weekend { color: var(--muted); }

.gantt { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem 0; }
.gantt .lane { position: relative; height: 2rem; border-bottom: 1px dashed var(--line); }
.gantt .lane .label { position: absolute; left: .5rem; top: .35rem; font-size: .8rem; z-index: 2;
  background: rgba(255,255,255,.85); padding: 0 .25rem; }
.gantt .bar { position: absolute; top: .3rem; height: 1.4rem; background: var(--accent); border-radius: 3px; opacity: .85; }
.gantt .wait { position: absolute; top: .65rem; height: .7rem; background: #9db8ae; border-radius: 2px; }
.gantt .latest { position: absolute; top: 0; bottom: 0; width: 2px; background: #c58b00; }
.gantt .marker { position: absolute; top: 0; bottom: 0; width: 2px; }
.gantt .marker.today { background: #888; }
.gantt .marker.promised { background: var(--error); }

@media (max-width: 860px) {
  .designer { grid-template-columns: 1fr; height: auto; }
  .designer .viewport { height: 55vh; }
  .admin { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}
