:root {
  --bg: #F3F2EE; --card: #FFFFFF; --ink: #1B1F1D; --dim: #5C625E; --line: #DEDBD2; --line2: #ECEAE3;
  --ok: #2E6B3A; --warn: #8A4B12; --accent: #3D6B45; --head: #F7F6F2; --bar: #E6E3DB;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 'Inter Tight', system-ui, -apple-system, sans-serif; }
a { color: var(--ink); } a:hover { color: var(--accent); }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.main { padding-top: 24px; padding-bottom: 64px; display: flex; flex-direction: column; gap: 20px; }
.narrow { max-width: 560px; margin: 0 auto; width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
.small { font-size: 14px; } .tiny { font-size: 12px; }
.strong { font-weight: 700; }
.ok { color: var(--ok); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
h1 { font-size: 28px; margin: 0; } h2 { font-size: 20px; margin: 0; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); margin: 0; }

/* header */
.top { background: var(--ink); color: #F3F2EE; }
.top-in { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: #F3F2EE; text-decoration: none; font-weight: 600; }
.brand:hover { color: #fff; }
.mark { font-family: var(--mono); font-weight: 700; font-size: 15px; background: #C9D8B6; color: var(--ink); padding: 6px 8px; border-radius: 6px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { color: #C4C8C3; text-decoration: none; padding: 11px 12px; border-radius: 8px; font-size: 15px; }
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #F3F2EE; background: #2C332F; font-weight: 600; }
.logout { margin-left: auto; }
.btn-ghost { min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid #3A423D; background: transparent; color: #F3F2EE; font: inherit; cursor: pointer; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.month { display: flex; align-items: center; gap: 8px; }
.month-label { font-weight: 600; min-width: 140px; text-align: center; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font-size: 20px; }
.link-sm { font-size: 14px; font-weight: 600; }
.flash { background: #EAF1E6; color: #2E5233; border-radius: 10px; padding: 12px 14px; font-weight: 600; }
.flash.bad { background: #F8E3DE; color: #8A2414; }

/* hero */
.hero { display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: flex-end; }
.hero-left { flex: 1 1 260px; display: flex; flex-direction: column; gap: 6px; }
.hero-right { flex: 2 1 380px; display: flex; flex-direction: column; gap: 10px; position: relative; padding-bottom: 20px; }
.big { display: flex; align-items: baseline; gap: 10px; }
.big .mono:first-child { font-size: 60px; font-weight: 700; line-height: 1; }
.big .dim { font-size: 22px; }
.bar { position: relative; display: block; height: 10px; background: var(--bar); border-radius: 5px; }
.big-bar { height: 16px; border-radius: 8px; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; display: block; background: var(--c, var(--accent)); border-radius: inherit; transition: width .25s ease; }
.fill.dark { background: var(--ink); }
.marker { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--ink); display: block; }
.big-bar .marker { background: #B5651D; top: -6px; bottom: -6px; }
.marker-label { position: absolute; bottom: 0; transform: translateX(-50%); font-size: 13px; color: var(--warn); white-space: nowrap; }

/* groups */
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.group-card { text-align: left; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 12px; border-width: 2px; }
.group-card[aria-pressed="true"] { border-color: var(--c); }
.group-card .sub { font-size: 14px; min-height: 40px; }
.tag { font-size: 13px; font-weight: 700; letter-spacing: .04em; padding: 5px 9px; border-radius: 6px; background: var(--t, #EEE); color: var(--c, var(--ink)); }
.log .tag { background: #F1EFE9; }
.g-num { display: flex; align-items: baseline; gap: 6px; }
.g-num .mono:first-child { font-size: 38px; font-weight: 700; line-height: 1; }

/* activities */
.panel { display: flex; flex-direction: column; gap: 14px; }
.panel[hidden] { display: none; }
.panel-head p { margin: 4px 0 0; }
.table-box { overflow-x: auto; border: 1px solid var(--line2); border-radius: 10px; }
.acts { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 15px; }
.acts th { background: var(--head); text-align: left; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 11px 12px; font-weight: 600; }
.acts td { padding: 10px 12px; border-top: 1px solid var(--line2); vertical-align: top; }
.acts tfoot th, .acts tfoot td { border-top: 2px solid var(--ink); background: var(--head); color: var(--ink); font-size: 15px; }
.r { text-align: right; } .c { text-align: center; }
.act-name { font-weight: 600; }
.dod { font-size: 13px; color: var(--dim); margin-top: 3px; max-width: 560px; }
.dod.note { font-style: italic; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: #F1E7DA; color: #7A4510; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 6px; }
.stepper form { margin: 0; }
.step { width: 44px; height: 44px; border-radius: 8px; font-size: 20px; cursor: pointer; border: 1px solid #D6D3CA; background: var(--card); color: var(--ink); }
.step.plus { background: var(--ink); color: #fff; border-color: var(--ink); }
.step:disabled { opacity: .5; }
.count { min-width: 34px; text-align: center; font-weight: 700; font-size: 17px; }

/* phone: activity rows as cards */
@media (max-width: 680px) {
  .table-box:has(.acts) { border: none; overflow: visible; }
  .acts { min-width: 0; }
  .acts thead { display: none; }
  .acts, .acts tbody, .acts tfoot { display: block; }
  .acts tr { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 12px; align-items: center;
             padding: 12px 0; border-top: 1px solid var(--line2); }
  .acts td { border: none; padding: 0; }
  .acts td:nth-child(1) { grid-column: 1 / -1; }
  .acts td:nth-child(2)::before { content: 'p/vien. '; font-family: inherit; color: var(--dim); font-size: 12px; }
  .acts td:nth-child(3)::before { content: 'vēlamais '; font-family: inherit; color: var(--dim); font-size: 12px; }
  .acts td:nth-child(2), .acts td:nth-child(3) { text-align: left; font-size: 14px; }
  .acts td:nth-child(4) { grid-column: 1 / 3; }
  .acts td:nth-child(4) .stepper { justify-content: flex-start; }
  .acts td:nth-child(5) { grid-column: 3; grid-row: 2 / 4; text-align: right; font-size: 17px; }
  .acts tfoot tr { grid-template-columns: 1fr auto; border-top: 2px solid var(--ink); background: var(--head); padding: 12px; border-radius: 0 0 8px 8px; }
  .acts tfoot td:empty { display: none; }
  .acts tfoot td:last-child { grid-column: 2; grid-row: 1; }
  .big .mono:first-child { font-size: 48px; }
  .month-label { min-width: 0; }
  .top-in { gap: 8px 12px; }
  .nav a { padding: 10px 8px; font-size: 14px; }
}

.rules ul { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: #3A403C; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; max-width: calc(100% - 32px); font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 10; }
.toast a { color: #C9D8B6; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
fieldset { border: 1px solid var(--line2); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 700; padding: 0 6px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; min-height: 44px; padding: 8px 12px; border: 1px solid #CFCBC0; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 64px; resize: vertical; }
input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; }
.btn { min-height: 48px; padding: 0 20px; border-radius: 10px; border: none; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.btn-sm { min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn-sm.danger { background: #fff; color: #8A2414; border-color: #D9B3AB; }
.code { background: #F1EFE9; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }

/* log */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 20px; border: 1px solid #D6D3CA; background: #fff; text-decoration: none; font-size: 14px; font-weight: 600; }
.chip[aria-current="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.log-item { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.log-top { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.log-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.log-actions { display: flex; gap: 8px; }
.empty { text-align: center; color: var(--dim); }

/* settings */
.settings-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.settings-table th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--dim); padding: 8px; background: var(--head); }
.settings-table td { padding: 8px; border-top: 1px solid var(--line2); vertical-align: top; }
.settings-table input[type=number] { width: 90px; }
.settings-table .w-name { min-width: 220px; }
.settings-table .w-text { min-width: 260px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.section-gap { display: flex; flex-direction: column; gap: 14px; }
