:root {
  --paper: #f8f5f2;
  --surface: #fffdfb;
  --ink: #1d2b36;
  --muted: #7d858c;
  --line: #e9e1db;
  --teal: #247c76;
  --teal-soft: #e4f1ef;
  --clay: #c96f4a;
  --red: #b74732;
  --blue: #6485b4;
  --shadow: 0 18px 48px rgba(40, 28, 20, 0.08);
}

* { box-sizing: border-box }
html { background: var(--paper); color: var(--ink); scroll-behavior: smooth }
body { margin: 0; font-family: "Sora", "Inter", Arial, sans-serif; background: radial-gradient(circle at 78% -15%, #e6f2ef 0, transparent 32%), var(--paper) }
button, input, select { font: inherit }
button { cursor: pointer }
main { width: min(1700px, calc(100% - 24px)); margin: 0 auto; padding: 12px 0 10px }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px }
.eyebrow { display: inline-flex; padding: 7px 11px; margin-bottom: 12px; border-radius: 999px; color: var(--teal); background: var(--teal-soft); font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase }
.hero h1 { margin: 0; font-size: clamp(32px, 4vw, 54px); letter-spacing: -.055em; line-height: .98 }
.hero p { margin: 12px 0 0; color: var(--muted); font-size: 18px }
.rule-card { min-width: 305px; display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid #cfe3df; border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: 0 10px 30px rgba(36,124,118,.08) }
.rule-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--teal); color: #fff; font-size: 24px; font-weight: 800 }
.rule-card div { display: flex; flex-direction: column; gap: 2px }
.rule-card strong { font-size: 14px }
.rule-card small { color: var(--muted) }

.simple-hero { min-height: 38px; align-items: center; margin-bottom: 6px }
.simple-hero h1 { font-size: clamp(26px, 3vw, 36px); text-transform: none }
.controls { display: grid; grid-template-columns: 190px 230px minmax(230px, 1fr) auto; align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,253,251,.9); box-shadow: var(--shadow) }
.controls label { display: flex; flex-direction: column; gap: 4px }
.controls label > span { color: #69737b; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase }
.controls input[type="month"], .controls select { width: 100%; height: 36px; padding: 0 11px; border: 1px solid #dfd5ce; border-radius: 9px; color: var(--ink); background: #fff }
.variation-control { padding: 0 8px 4px }
.variation-control input { width: 100%; accent-color: var(--teal) }
.variation-control b { color: var(--teal); font-size: 13px }
.primary, .secondary { height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 750; white-space: nowrap; transition: transform .15s ease, box-shadow .15s ease }
.primary { border: 1px solid var(--teal); color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(36,124,118,.2) }
.secondary { border: 1px solid #dfc8bd; color: #a3442f; background: #fff }
.primary:hover, .secondary:hover { transform: translateY(-1px) }
.primary:disabled, .secondary:disabled { cursor: not-allowed; opacity: .45; transform: none }
.primary:focus-visible, .secondary:focus-visible, .person:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(36,124,118,.25); outline-offset: 2px }
.control-actions { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding-top: 6px; border-top: 1px solid var(--line) }
.action-spacer { flex: 1 }
.secondary.download { color: #fff; border-color: #394e61; background: #394e61 }

.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 16px 0 }
.metric { min-height: 118px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: 18px 22px; border-radius: 18px; color: #fff }
.metric::after { content: ""; position: absolute; width: 90px; height: 90px; right: -30px; top: -30px; border: 20px solid rgba(255,255,255,.08); border-radius: 50% }
.metric span { font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; opacity: .84 }
.metric strong { margin-top: 2px; font-size: 34px; line-height: 1; letter-spacing: -.05em }
.metric small { margin-top: 6px; opacity: .82 }
.metric.teal { background: linear-gradient(135deg, #47948e, #1d6e69) }
.metric.clay { background: linear-gradient(135deg, #dc906d, #bd5f3d) }
.metric.red { background: linear-gradient(135deg, #c85f48, #a73926) }
.metric.blue { background: linear-gradient(135deg, #819dcc, #5577a6) }
.metric.ink { background: linear-gradient(135deg, #444, #242424) }

.workspace { display: grid; grid-template-columns: minmax(330px, 28%) 1fr; min-height: 640px; margin-top: 8px; overflow: visible; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow) }
.people-panel { border-right: 1px solid var(--line); background: #fbf9f7 }
.panel-heading, .points-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line) }
.panel-heading div, .points-heading > div:first-child { min-width: 0 }
.panel-heading span, .points-heading span { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase }
.panel-heading h2, .points-heading h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -.025em }
.count { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); color: var(--teal) !important; font-size: 13px !important }
.people-list { max-height: 700px; overflow: auto; scrollbar-color: #d6ccc5 transparent }
.person { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) 18px; align-items: center; gap: 9px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; transition: background .15s ease }
.person:hover { background: #f1f7f6 }
.person.active { background: var(--teal-soft); box-shadow: inset 4px 0 var(--teal) }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: #e9ded7; color: #85513c; font-size: 12px; font-weight: 800 }
.person.active .avatar { background: var(--teal); color: #fff }
.person-copy { min-width: 0; display: flex; flex-direction: column }
.person-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px }
.person-copy small { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap }
.person-copy em { margin-top: 5px; color: var(--teal); font-size: 10px; font-style: normal; font-weight: 700 }
.arrow { color: #a9a19b; font-size: 22px }

.points-panel { min-width: 0 }
.points-heading { min-height: 105px }
.points-heading h2 { overflow: hidden; max-width: 760px; text-overflow: ellipsis; white-space: nowrap }
.points-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px }
.shift-pill { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 10px 13px; border: 1px solid #cfe3df; border-radius: 12px; background: #f1f8f7 }
.shift-pill strong { font-size: 14px }
.shift-pill small { margin-top: 2px; color: var(--muted) }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; min-height: 48px; padding: 10px 24px; border-bottom: 1px solid var(--line); color: #6f777d; font-size: 11px }
.legend span { display: flex; align-items: center; gap: 6px }
.legend-note { margin-left: auto }
.dot { width: 8px; height: 8px; border-radius: 50% }
.dot.planned { background: var(--teal) }
.dot.dayoff { background: #c5b7ae }
.dot.absence { background: var(--red) }

.month-summary { padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fbfdfc }
.summary-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 11px }
.summary-title > div { display: flex; flex-direction: column; gap: 2px }
.summary-title span { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase }
.summary-title small { color: var(--muted); font-size: 10px }
.bank-button { height: 34px; padding: 0 12px; font-size: 11px }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px }
.summary-grid article { min-width: 0; padding: 10px 11px; border: 1px solid #e5ded8; border-radius: 11px; background: #fff }
.summary-grid article > span { display: block; overflow: hidden; color: #737b80; font-size: 9px; font-weight: 800; letter-spacing: .035em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap }
.summary-grid article strong { display: block; margin-top: 4px; font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: -.035em }
.summary-grid article small { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap }
.summary-grid article.positive strong { color: var(--teal) }
.summary-grid article.negative strong { color: var(--red) }
.summary-disclaimer { margin: 9px 0 0; color: #7c817f; font-size: 9px; line-height: 1.35 }

.table-wrap { max-height: none; overflow: visible }
table { width: 100%; border-collapse: collapse }
thead { position: sticky; top: 0; z-index: 2; background: #f7f3ef }
th { padding: 12px 14px; color: #767d82; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-align: left; text-transform: uppercase }
td { height: 58px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px }
tbody tr:hover { background: #fbfdfd }
td:first-child { width: 72px }
td:first-child b { display: block; font-size: 15px }
td:first-child span { color: var(--muted); font-size: 10px }
.point-cell strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums }
.time-button { min-width: 58px; padding: 6px 8px; border: 1px solid transparent; border-radius: 7px; color: var(--ink); background: transparent; font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; text-align: left }
.time-button:hover { border-color: #bad7d3; color: var(--teal); background: var(--teal-soft) }
.time-button:focus-visible { outline: 3px solid rgba(36,124,118,.25); outline-offset: 1px }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 750 }
.status-work { color: var(--teal); background: var(--teal-soft) }
.status-dayoff { color: #71665f; background: #e8e0db }
.status-vacation { color: #fff; background: var(--teal) }
.status-medical { color: #fff; background: var(--red) }
tr.status-dayoff, tr.status-vacation, tr.status-medical { background: #faf8f6 }
.no-points { color: #a59c96; font-size: 11px; font-style: italic }
.edit-empty { padding: 5px 7px; border: 1px dashed transparent; border-radius: 7px; background: transparent }
.edit-empty:hover { border-color: #c9bbb2; color: #6f625a }

.month-complete .points-heading { min-height: 46px; padding: 5px 12px }
.month-complete .points-heading h2 { margin-top: 1px; font-size: 17px }
.month-complete .points-heading p { margin-top: 1px; font-size: 9px }
.month-complete .shift-pill { padding: 7px 10px }
.month-complete .shift-pill strong { font-size: 11px }
.month-complete .month-summary { padding: 4px 10px }
.month-complete .summary-title { margin-bottom: 5px }
.month-complete .summary-title small { font-size: 8px }
.month-complete .bank-button { height: 28px; font-size: 9px }
.month-complete .summary-grid { gap: 5px }
.month-complete .summary-grid article { padding: 3px 6px; border-radius: 7px }
.month-complete .summary-grid article > span { font-size: 7.5px }
.month-complete .summary-grid article strong { margin-top: 1px; font-size: 14px }
.month-complete .summary-grid article small { margin-top: 1px; font-size: 7px }
.month-complete .summary-disclaimer { margin-top: 2px; font-size: 7px; line-height: 1.1 }
.month-complete .legend { min-height: 20px; padding: 2px 10px; gap: 8px; font-size: 7.5px }
.month-complete .dot { width: 6px; height: 6px }
.month-complete .table-wrap { overflow: visible }
.month-complete table { min-width: 0; table-layout: fixed }
.month-complete thead { position: static }
.month-complete th { height: 14px; padding: 2px 8px; font-size: 7px; line-height: 1 }
.month-complete td { height: 14px; padding: 0 8px; font-size: 8.5px; line-height: 1 }
.month-complete td:first-child { width: 56px }
.month-complete td:first-child b { display: inline; font-size: 9px }
.month-complete td:first-child span { margin-left: 4px; font-size: 7px }
.month-complete .time-button { min-width: 40px; padding: 0 3px; font-size: 8.5px; line-height: 1 }
.month-complete .status { padding: 1px 4px; font-size: 7px }
.month-complete .no-points { font-size: 7px }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(25,32,37,.48); backdrop-filter: blur(3px) }
.modal-card { width: min(100%, 470px); display: flex; flex-direction: column; gap: 14px; padding: 24px; border-radius: 18px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.2) }
.modal-card h2 { margin: 0; font-size: 22px; letter-spacing: -.03em }
.modal-card > p { margin: -8px 0 3px; color: var(--muted); font-size: 12px }
.modal-card label { display: flex; flex-direction: column; gap: 6px }
.modal-card label > span { color: #6d7479; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase }
.modal-card input, .modal-card select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #ddd2cb; border-radius: 10px; background: #fff }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 5px }
.modal-actions .primary, .modal-actions .secondary { height: 42px }
.modal-actions .reset { color: #8b3d2d }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px }
.modal-hint { padding: 9px 11px; border-radius: 9px; color: #50666a; background: #edf5f4; font-size: 11px }
.print-area { display: none }

footer { padding: 18px 4px 0; color: var(--muted); font-size: 12px; text-align: center }
footer strong { color: var(--ink) }

.fp-message { width:min(1700px,calc(100% - 48px)); margin:-10px auto 16px; padding:10px 13px; border:1px solid #cfe3df; border-radius:10px; color:#315d5a; background:#eef8f6; font-size:12px }
.fp-message.warning { color:#7a4c1d; border-color:#ecd6b5; background:#fff8e9 }
.fp-message.error { color:#8b2f25; border-color:#efc7c1; background:#fff1ef }
.fp-message.success { color:#17643f; border-color:#b9dec8; background:#edf9f1 }
.fp-loading,.fp-empty { padding:24px; color:var(--muted); text-align:center }
.fp-empty h2 { margin:0 0 6px; color:var(--ink) }

@media (max-width: 1180px) {
  .controls { grid-template-columns: repeat(3, 1fr) }
  .metrics { grid-template-columns: repeat(3, 1fr) }
  .workspace { grid-template-columns: 340px 1fr }
}
@media (max-width: 820px) {
  main { width: min(100% - 24px, 680px); padding-top: 20px }
  .hero { align-items: stretch; flex-direction: column }
  .rule-card { min-width: 0 }
  .controls { grid-template-columns: 1fr 1fr }
  .metrics { grid-template-columns: 1fr 1fr }
  .workspace { grid-template-columns: 1fr }
  .people-panel { border-right: 0; border-bottom: 1px solid var(--line) }
  .people-list { max-height: 320px }
  .points-heading { align-items: flex-start; flex-direction: column }
  .shift-pill { align-items: flex-start }
  .legend-note { width: 100%; margin-left: 0 }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .table-wrap { max-height: none; overflow-x: auto; overflow-y: visible }
  table { min-width: 690px }
  .control-actions .action-spacer { display: none }
}
@media (max-width: 520px) {
  .controls, .metrics { grid-template-columns: 1fr }
  .metric { min-height: 92px }
  .hero h1 { font-size: 36px }
  .control-actions { align-items: stretch; flex-direction: column }
  .control-actions button { width: 100% }
  .time-grid { grid-template-columns: 1fr }
  .summary-title { align-items: stretch; flex-direction: column }
  .summary-title button { width: 100% }
}

@media print {
  @page { size: A4 portrait; margin: 7mm 8mm }
  html, body { width: 210mm; min-height: 297mm; background: #fff }
  body { margin: 0; font-size: 8pt }
  .app-shell, .modal { display: none !important }
  .print-area { display: block !important }
  .print-sheet { position: relative; width: 100%; height: 275mm; margin: 0; color: #111; background: #fff; break-after: page; page-break-after: always; overflow: hidden }
  .print-sheet:last-child { break-after: auto; page-break-after: auto }
  .sheet-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 8mm; height: 19mm; padding-bottom: 2mm; border-bottom: .3mm solid #555 }
  .sheet-header span { color: #156e69; font-size: 7pt; font-weight: 800; letter-spacing: .06em; text-transform: uppercase }
  .sheet-header h1 { max-width: 145mm; margin: .8mm 0 0; overflow: hidden; font-size: 13pt; line-height: 1.05; text-overflow: ellipsis; white-space: nowrap }
  .sheet-header p { margin: .8mm 0 0; font-size: 6.7pt; line-height: 1.1 }
  .sheet-header > div:last-child { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; padding: 1.2mm 2mm; border: .2mm solid #bcd6d3; border-radius: 2mm }
  .sheet-header strong { font-size: 8.5pt }
  .sheet-header small { margin-top: .5mm; font-size: 6.2pt }
  .sheet-table { width: 100%; table-layout: fixed; border-collapse: collapse }
  .sheet-table thead { position: static; display: table-header-group; background: #f3f0ed }
  .sheet-table th { height: 5mm; padding: .65mm 1mm; border-bottom: .2mm solid #bbb; font-size: 6.2pt; line-height: 1 }
  .sheet-table tbody tr { height: 5.8mm; break-inside: avoid }
  .sheet-table td { height: 5.8mm; padding: .45mm 1mm; border-top: .2mm solid #ddd; font-size: 7.1pt; line-height: 1; vertical-align: middle }
  .sheet-table th:first-child, .sheet-table td:first-child { width: 16mm }
  .sheet-table td:first-child b { display: inline; font-size: 7.8pt }
  .sheet-table td:first-child span { margin-left: 1.5mm; color: #666; font-size: 6pt }
  .sheet-table th:last-child, .sheet-table td:last-child { width: 23mm }
  .sheet-summary { margin-top: 1.5mm; padding: 1.5mm 2mm; border: .2mm solid #c7d8d6; border-radius: 1.8mm; background: #f7fbfa }
  .sheet-summary h2 { margin: 0 0 1.2mm; color: #156e69; font-size: 6.5pt; letter-spacing: .05em; text-transform: uppercase }
  .sheet-summary > div { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1.5mm }
  .sheet-summary article { min-width: 0 }
  .sheet-summary span { display: block; overflow: hidden; color: #555; font-size: 5.4pt; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap }
  .sheet-summary strong { display: block; margin-top: .5mm; font-size: 7.4pt; font-variant-numeric: tabular-nums }
  .sheet-summary p { margin: 1.2mm 0 0; color: #555; font-size: 5.2pt; line-height: 1.1 }
  .sheet-footer { position: absolute; right: 0; bottom: 1mm; left: 0; display: grid; grid-template-columns: 1fr 1fr 45mm; gap: 8mm; padding-top: 8mm; background: #fff }
  .sheet-footer span { border-top: .25mm solid #555; padding-top: 1mm; font-size: 6.5pt; text-align: center }
}
