/* VKRI shared UI kit: reset, type, and the components both interfaces use. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 400 var(--t-md)/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* type */
.display { font-family: var(--display); font-weight: 500; line-height: 1.08; letter-spacing: -0.01em; text-wrap: balance; }
.d-xl { font-size: var(--d-xl); } .d-lg { font-size: var(--d-lg); } .d-md { font-size: var(--d-md); } .d-sm { font-size: var(--d-sm); line-height: 1.2; }
.eyebrow { font-size: var(--t-xs); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); } .soft { color: var(--ink-2); }
.small { font-size: var(--t-sm); } .xs { font-size: var(--t-xs); }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.italic { font-style: italic; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* layout helpers */
.row { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.grow { flex: 1 1 0; min-width: 0; }
.gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); } .gap-4 { gap: var(--s4); } .gap-5 { gap: var(--s5); } .gap-6 { gap: var(--s6); }
.grid { display: grid; gap: var(--s4); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); }
.panel-pad { padding: var(--s4) var(--s5); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }
.list > * + * { border-top: 1px solid var(--line); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--on-night); border-color: var(--ink); }
.btn.primary:hover { background: #2A3544; }
.btn.accent { background: var(--wed); color: #fff; border-color: var(--wed); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.sm { min-height: 34px; padding: 0 var(--s3); font-size: var(--t-xs); }
.btn.block { width: 100%; }
@media (max-width: 767px) { .btn.sm { min-height: 44px; padding: 0 var(--s4); } }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }

/* pills: state is always a word plus a colour, never colour alone */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: var(--t-xs); font-weight: 600; white-space: nowrap;
  background: var(--idle-soft); color: var(--ink-2); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.wed { background: var(--wed-soft); color: var(--wed); }
.pill.plain::before { display: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border: 1px solid var(--line-2); border-radius: 4px; font-size: var(--t-xs); color: var(--ink-2); white-space: nowrap; }
.tag.internal { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.tag.public { border-color: var(--good); color: var(--good); background: var(--good-soft); }

/* avatar */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--sunken); color: var(--ink-2); font-size: 0.6875rem; font-weight: 700; letter-spacing: .02em; border: 1px solid var(--line-2); }
.avatar.lg { width: 44px; height: 44px; font-size: var(--t-sm); }
.avatar.couple { background: var(--wed-soft); color: var(--wed); border-color: transparent; }

/* progress */
.bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--ink); }
.bar.wed > i { background: var(--wed); } .bar.good > i { background: var(--good); } .bar.crit > i { background: var(--crit); }
.bar.thin { height: 4px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { text-align: left; font-weight: 600; font-size: var(--t-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table td { padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: var(--sunken); }

/* tabs and segmented control */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { padding: var(--s3) 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink-3); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; display: inline-flex; align-items: center; }
.tabs .on { color: var(--ink); border-bottom-color: var(--wed); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--sunken); gap: 2px; }
.seg button { min-height: 34px; padding: 0 var(--s4); border-radius: 999px; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(26, 34, 45, .12); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); }
.field > span { font-weight: 600; }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r1); background: var(--surface); font-size: 1rem; }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--brass); outline-offset: 0; border-color: transparent; }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-size: var(--t-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* key/value */
.kv { display: grid; grid-template-columns: minmax(96px, 30%) 1fr; gap: 6px var(--s4); font-size: var(--t-sm); }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* sheet: bottom sheet on phones, right-hand drawer on laptops */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; background: rgba(26, 34, 45, .38); }
.sheet { background: var(--surface); width: min(520px, 100%); height: 100%; overflow-y: auto; padding: var(--s5); padding-bottom: calc(var(--s5) + var(--safe-b)); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: var(--s4); }
.sheet-close { align-self: flex-end; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; margin: calc(-1 * var(--s3)) calc(-1 * var(--s3)) 0 0; }
.sheet-close:hover { background: var(--sunken); }
@media (max-width: 767px) {
  .sheet-wrap { align-items: flex-end; }
  .sheet { width: 100%; height: auto; max-height: 88dvh; border-radius: var(--r3) var(--r3) 0 0; }
}

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(88px + var(--safe-b)); transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--on-night);
  padding: 10px 18px; border-radius: 999px; font-size: var(--t-sm); font-weight: 600; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; }

/* misc */
.demo-flag { font-size: var(--t-xs); color: var(--ink-3); text-align: center; padding: var(--s5) var(--s4); }
.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--ink-3); font-size: var(--t-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wed); flex: none; display: inline-block; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.stat .n { font-family: var(--display); font-size: var(--d-md); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums lining-nums; }
.stat .l { font-size: var(--t-xs); color: var(--ink-3); margin-top: 6px; }
.tone-late, .tone-crit { color: var(--crit); } .tone-soon, .tone-today, .tone-warn { color: var(--warn); } .tone-good { color: var(--good); }

/* back / forward inside the interface: two quiet arrows */
.navarrows { display: inline-flex; align-items: center; gap: 2px; margin-left: -10px; }
.navarrows button { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--ink-2); transition: background .15s; }
.navarrows button:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.navarrows button:disabled { color: var(--line-2); cursor: default; }
.navarrows .icon { width: 20px; height: 20px; stroke-width: 1.5; }
@media (max-width: 767px) { .navarrows button { width: 44px; height: 44px; } }
.demo-flag { padding: var(--s4); }
