:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #d5d9e0;
  --accent: #1f5fbf;
  --accent-weak: #e8f0fc;
  --grey: #d9d9d9;
  --danger: #b42318;
  --ok: #157f3b;
  --warn: #b54708;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: #16213a; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 17px; }
.topbar nav a { color: #c9d4ea; margin-right: 16px; }
.topbar .logout { color: #c9d4ea; margin-left: auto; }
.topbar .logout[hidden] { display: none; }

/* Pieslēgšanās */
form.login { max-width: 340px; margin: 60px auto; display: flex; flex-direction: column; gap: 12px; }
form.login label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
form.login input { font-size: 14px; padding: 7px 9px; }
form.login button { justify-content: center; padding: 7px 11px; }
.login-error { color: var(--danger); font-size: 13px; }
.login-error[hidden] { display: none; }
main { max-width: 1400px; margin: 0 auto; padding: 18px 20px 80px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.crumbs { color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.grow { flex: 1; }
.spacer { flex: 1; }
.head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

input, textarea, select {
  font: inherit; color: inherit; border: 1px solid var(--border); border-radius: 5px; padding: 5px 7px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; }
textarea { width: 100%; resize: vertical; min-height: 34px; }

button, .btn {
  font: inherit; border: 1px solid var(--border); background: #fff; border-radius: 5px; padding: 5px 11px; cursor: pointer;
  color: var(--text); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
button:hover, .btn:hover { background: #f0f2f5; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #194f9f; }
button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 2px 4px; color: var(--accent); }
button.icon { padding: 2px 6px; font-size: 12px; color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eceef2; vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.list input:not([type=checkbox]) { width: 100%; }
tr.inactive td { opacity: .5; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; display: block; color: inherit; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card .title { font-weight: 600; font-size: 15px; margin-bottom: 4px; color: var(--accent); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: #eef0f3; color: var(--muted); }
.badge.draft { background: #fff4e5; color: var(--warn); }
.badge.finished { background: #e8f0fc; color: var(--accent); }
.badge.closed { background: #e6f4ea; color: var(--ok); }

/* Protokols */
.legend { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.new, .new input, .new textarea { font-style: italic; }
.struck, .struck input, .struck textarea { text-decoration: line-through; color: #8a8f99; }
.proto { width: 100%; border-collapse: collapse; background: #fff; }
.proto th { background: var(--grey); font-size: 12px; padding: 6px; border: 1px solid #bfc3c9; }
.proto td { border: 1px solid #cfd3d9; padding: 6px; vertical-align: top; }
.proto .c-nr { width: 84px; font-weight: 600; text-align: center; }
.proto .c-nr .nr { display: flex; align-items: center; gap: 6px; justify-content: center; }
.proto .c-resp { width: 120px; }
.proto .c-todo { width: 90px; }
.proto .c-dl { width: 180px; }
.proto .c-act { width: 90px; text-align: right; white-space: nowrap; }
.proto tr.topic td { background: #f1f2f4; font-weight: 700; }
.proto tr.topic.d1 td { background: var(--grey); text-transform: uppercase; }
.proto tr.topic input.title { font-weight: 700; width: 100%; background: transparent; }
.proto tr.topic.d1 input.title { text-transform: uppercase; }
.proto td input { width: 100%; }
.entry { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.entry .date { width: 128px; flex: none; }
.entry .text { flex: 1; white-space: pre-wrap; }
.entry .readonly-date { flex: none; color: inherit; }
.entry .tools { flex: none; display: flex; gap: 2px; }
.orig { font-size: 12px; color: var(--muted); margin-top: 3px; }
.done-flag { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; }
.done-label { color: var(--ok); font-weight: 700; }
.addbar { display: flex; gap: 6px; margin-top: 4px; }
.overdue, input.overdue, .struck .overdue { color: var(--danger) !important; font-weight: 600; }
.prev-resp { text-decoration: line-through; font-style: normal; color: #8a8f99; }
.prev-resp:empty { display: none; }

/* Datuma (DD.MM.YYYY) un laika (24h) lauki */
.datefield { display: inline-flex; align-items: center; gap: 2px; position: relative; }
.datefield .date-text { width: 108px; }
.datefield .cal { padding: 2px 4px; font-size: 13px; border-color: transparent; background: transparent; }
.time-text { width: 80px; }
input.invalid { border-color: var(--danger); outline: 2px solid #fde2e0; }
.proto td .datefield .date-text { width: 100%; min-width: 96px; }
.proto td .datefield { display: flex; }
.proto .entry .datefield { display: inline-flex; flex: none; }
.proto .entry .datefield .date-text { width: 100px; min-width: 0; }

/* "+" pogas un pievienošanas rindas */
button.plus {
  width: 22px; height: 22px; padding: 0; border-radius: 50%; justify-content: center; flex: none;
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; font-size: 15px; line-height: 1;
}
button.plus:hover { background: #194f9f; }
.proto tr.add-row td { background: #fbfcfe; border-top-style: dashed; padding: 3px 6px; }
.proto tr.add-row .next-nr { color: var(--muted); font-style: italic; font-weight: 400; }
.proto tr.add-row .add-link { color: var(--accent); }
.proto tr.add-row .add-alt { color: var(--muted); font-size: 12px; margin-left: 8px; }
.proto tr.add-row.sub td { background: #f6f7f9; }
.proto tr.add-row.root td { background: #eef0f3; }
.proto tr.add-row:hover td { background: var(--accent-weak); }

/* Izkrītošais saraksts */
.combo { position: relative; display: flex; align-items: center; }
.combo input { flex: 1; min-width: 0; }
.combo .combo-btn { padding: 2px 4px; border-color: transparent; background: transparent; }
.combo-list { position: absolute; top: 100%; left: 0; z-index: 30; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.15); max-height: 260px; overflow-y: auto; min-width: 240px; margin-top: 2px;
  font-style: normal; text-decoration: none; }
.combo-opt { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; color: var(--text); }
.combo-opt b { min-width: 42px; }
.combo-opt .muted { font-size: 12px; }
.combo-opt:hover, .combo-opt.active { background: var(--accent-weak); }

.code { display: inline-block; font-size: .8em; font-weight: 700; color: #fff; background: #16213a; border-radius: 4px; padding: 1px 7px; margin-right: 8px; vertical-align: middle; }

.attendance td.present { width: 70px; text-align: center; }
.links li { margin-bottom: 4px; word-break: break-all; }

.result { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.result .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.result .entries div { margin: 3px 0; white-space: pre-wrap; }
mark { background: #fff1a8; padding: 0 1px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #16213a; color: #fff; padding: 9px 16px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.2); z-index: 10; }
.toast.error { background: var(--danger); }

dialog { border: 1px solid var(--border); border-radius: 10px; padding: 18px; min-width: 340px; }
dialog::backdrop { background: rgba(15, 23, 42, .35); }
dialog .row { margin-bottom: 12px; }

@media (max-width: 800px) {
  main { padding: 12px; }
  .proto .c-act { width: auto; }
  .entry { flex-wrap: wrap; }
}
@media print {
  .topbar, button, .addbar, .no-print { display: none !important; }
}

/* Sakļaujams panelis (piem., jauna sapulču plūsma) */
details.collapsible > summary { list-style: none; cursor: pointer; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible:not([open]) { padding: 12px 16px; }
details.collapsible[open] > summary .btn { background: #fff; color: var(--text); border-color: var(--border); }

/* Claude ieteikumi */
.suggestion { border: 1px solid #c7d7f5; background: #f3f7fe; border-radius: 6px; padding: 8px; margin: 2px 0 10px 106px;
  font-style: normal; text-decoration: none; color: var(--text); }
.suggestion .sg-head { font-size: 13px; margin-bottom: 6px; }
.suggestion textarea { font-style: normal; background: #fff; }
.suggestion .sg-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.suggestion-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #f3f7fe; border: 1px solid #c7d7f5; border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
@media (max-width: 800px) { .suggestion { margin-left: 0; } }

/* Dalībnieki sagrupēti pēc uzņēmuma */
table.attendance td { border-bottom-color: transparent; }
table.attendance tr.group-start td { border-top: 1px solid #d5d9e0; }
table.attendance td.company { font-weight: 600; }

/* Dalībnieka ieteikumi no citiem projektiem */
.person-suggest { position: relative; }
.person-suggest .combo-list { min-width: 320px; }
.person-suggest .combo-opt { flex-direction: column; gap: 1px; align-items: flex-start; }
.entry .tools .ai-entry { font-size: 13px; }
.entry .tools .ai-entry.busy { animation: ai-pulse 1s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .3; } }

/* Iestatījumi */
.model-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.model-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.model-opt:hover { background: var(--accent-weak); }
.model-opt input { margin-top: 3px; }
.model-opt .badge { margin-left: 8px; }
textarea.instructions { min-height: 220px; line-height: 1.45; }

/* Kalendārs (nedēļa sākas ar pirmdienu) */
.calendar { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); padding: 10px; width: 252px; font-style: normal; text-decoration: none; color: var(--text); }
.calendar .cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.calendar .cal-head button { font-size: 16px; padding: 0 8px; }
.calendar .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.calendar .cal-weekdays { color: var(--muted); font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.calendar .weekend { color: var(--danger); }
.calendar .cal-day { justify-content: center; padding: 5px 0; border: 1px solid transparent; background: none; }
.calendar .cal-day:hover { background: var(--accent-weak); }
.calendar .cal-day.today { border-color: var(--accent); }
.calendar .cal-day.selected { background: var(--accent); color: #fff; }
.calendar .cal-foot { margin-top: 6px; text-align: center; }

/* Pareizrakstības pasvītrojums */
.spell-wrap { position: relative; flex: 1; min-width: 0; background: #fff; border-radius: 5px; }
.spell-wrap textarea { position: relative; z-index: 1; background: transparent; display: block; }
.spell-mirror { position: absolute; inset: 0; z-index: 0; pointer-events: none; color: transparent; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: break-word; border: 1px solid transparent; box-sizing: border-box; }
.spell-mirror mark { background: none; color: transparent; text-decoration: underline wavy #d92d20; text-decoration-skip-ink: none; text-underline-offset: 2px; padding: 0; }
.spell-pop { position: absolute; top: 100%; left: 0; z-index: 40; background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); padding: 6px; min-width: 190px; display: flex; flex-direction: column; gap: 2px;
  font-style: normal; text-decoration: none; color: var(--text); }
.spell-pop .spell-opt { justify-content: flex-start; border: none; background: none; padding: 5px 8px; text-align: left; }
.spell-pop .spell-opt:hover { background: var(--accent-weak); }
.spell-pop .spell-ignore { color: var(--muted); font-size: 12px; border-top: 1px solid #eceef2; margin-top: 4px; padding-top: 7px; }

/* Ar roku maināms numurs */
button.numedit { font: inherit; font-weight: inherit; font-style: inherit; padding: 1px 6px; border: 1px dashed transparent; color: inherit; }
button.numedit:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
button.numedit.manual::after { content: '✎'; font-size: 10px; margin-left: 3px; color: var(--muted); }

/* Atbildīgo iniciāļu atšifrējums */
.resp-tip { position: fixed; z-index: 900; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; font-size: 13px; line-height: 1.4; pointer-events: none;
  font-style: normal; text-decoration: none; color: var(--text); }
.resp-tip .resp-group + .resp-group { margin-top: 6px; border-top: 1px solid #eceef2; padding-top: 6px; }
.resp-tip .resp-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.resp-tip .resp-line b { display: inline-block; min-width: 34px; }
.resp-tip .resp-line.unknown { color: var(--danger); }
