:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e2e6ea;
  --brand: #b5121b;
  --brand-dark: #8e0e15;
  --accent: #1d4ed8;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 1.5rem; min-height: 52px; flex-wrap: wrap; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a { color: #fff; padding: .35rem .7rem; border-radius: 6px; opacity: .9; }
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.18); text-decoration: none; opacity: 1; }
.topbar .user { margin-left: auto; display: flex; gap: .8rem; align-items: center; font-size: .9rem; }
.topbar .user a { color: #fff; text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.container.wide { max-width: 1400px; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.2rem; }
.card h2:first-child, .card h1:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=tel], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid #c9ced6; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: .9rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; margin-bottom: .9rem; }
.row > .field.short { flex: 0 1 140px; }
.checks label { display: flex; align-items: center; gap: .5rem; font-weight: 500; padding: .3rem 0; }
.checks input { width: auto; }
.inline { display: inline-flex; align-items: center; gap: .5rem; }

.btn { display: inline-block; padding: .5rem .95rem; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: #c9ced6; }
.btn-secondary:hover { background: #f1f3f5; }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: #1e40af; }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #166534; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
form.inline-form { display: inline; }

table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { background: #f8fafc; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #fafbfc; }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-gray { background: #e5e7eb; color: #374151; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .n { font-size: 1.7rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; }

.linkbox { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.linkbox input { flex: 1 1 320px; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }

.items-table td input { padding: .3rem .4rem; }
.items-table td.n input { text-align: right; width: 90px; }
.total-box { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.total-box .big { font-size: 1.35rem; font-weight: 700; }
.sticky-total { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--brand); padding: .7rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; z-index: 5; box-shadow: 0 -4px 12px rgba(0,0,0,.05); }

.service { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center; padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.service:last-child { border-bottom: none; }
.service .name { font-weight: 600; }
.service .desc { color: var(--muted); font-size: .85rem; }
.service .price { color: var(--muted); font-size: .85rem; }
.service .ctl input[type=number] { width: 90px; text-align: right; }
.service .ctl { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.service.selected .name { color: var(--brand-dark); }
.radio-group label { display: flex; gap: .5rem; align-items: center; font-weight: 500; padding: .25rem 0; }
.radio-group input { width: auto; }

.time-pick { display: inline-flex; align-items: center; gap: .3rem; }
.time-pick select { width: auto; min-width: 4.4rem; padding: .5rem .4rem; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.time-pick .tp-sep { font-weight: 700; font-size: 1.1rem; }
.hours-info { padding: .55rem 0; font-weight: 700; font-size: 1.05rem; color: var(--brand-dark); min-height: 2.3rem; }
.public h1 { color: var(--brand); }
.summary-box { background: #fff; border: 2px solid var(--brand); border-radius: var(--radius); padding: 1rem 1.2rem; }
.summary-box table { width: 100%; border-collapse: collapse; }
.summary-box td { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.summary-box td.num { text-align: right; white-space: nowrap; }
.summary-box tr.total td { font-weight: 700; border-bottom: none; font-size: 1.1rem; }

.diff-table td, .diff-table th { padding: .3rem .6rem; }
.diff-table td.old { color: #991b1b; text-decoration: line-through; }
.diff-table td.new { color: #166534; font-weight: 600; }

.login-box { max-width: 380px; margin: 4rem auto; }
.contract-preview { background: #fff; padding: 2cm; max-width: 21cm; margin: 0 auto; border: 1px solid var(--line); font-family: Calibri, Arial, sans-serif; font-size: 11pt; }
.contract-preview table { border-collapse: collapse; width: 100%; }
.contract-preview td, .contract-preview th { border: 1px solid #999; padding: 3px 6px; }
@media print { .topbar, .footer, .actions, .flash { display: none !important; } .contract-preview { border: none; padding: 0; } body { background: #fff; } .container { padding: 0; max-width: none; } }

.help { background: #f8fafc; border: 1px dashed #c9ced6; border-radius: var(--radius); padding: .6rem .9rem; font-size: .86rem; }
.help code { background: #e5e7eb; padding: .05rem .3rem; border-radius: 3px; }
.tag-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.tag-list code { cursor: pointer; }
.agenda tr.day th { background: #eef2f7; color: var(--text); text-transform: none; letter-spacing: 0; font-size: .95rem; padding: .5rem .7rem; }
.agenda tr.day.weekend th { background: #fdf2f2; }
.agenda tr.day.today th { background: #fef9c3; }
.agenda td.time { width: 130px; }
