*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --color-bg: #f4f6f9; --color-surface: #ffffff; --color-border: #e2e8f0;
  --color-primary: #2563eb; --color-primary-hover: #1d4ed8;
  --color-danger: #dc2626; --color-success: #16a34a; --color-warn: #f59e0b;
  --color-text: #1e293b; --color-muted: #64748b;
  --color-sidebar: #1e293b; --color-sidebar-text: #cbd5e1;
  --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,.1); --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg); color: var(--color-text); min-height: 100vh; }

/* Login */
body.login-page { display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%); }
.login-card { background: var(--color-surface); border-radius: 16px; padding: 48px 40px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 28px; font-weight: 700; margin-top: 8px; }
.login-subtitle { color: var(--color-muted); margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 14px; font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--color-border);
  border-radius: var(--radius); font-size: 14px; outline: none;
  background: var(--color-surface); color: var(--color-text); transition: border-color .15s; }
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: var(--radius); font-size: 14px;
  font-weight: 500; cursor: pointer; transition: background .15s, opacity .15s; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover:not(:disabled) { background: var(--color-bg); }
.btn-full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Messages */
.error-msg { background: #fef2f2; color: var(--color-danger); padding: 10px 14px;
  border-radius: var(--radius); font-size: 14px; border: 1px solid #fecaca; }
.success-msg { background: #f0fdf4; color: var(--color-success); padding: 10px 14px;
  border-radius: var(--radius); font-size: 14px; border: 1px solid #bbf7d0; }
.hidden { display: none; }
.loading { padding: 40px; text-align: center; color: var(--color-muted); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--color-sidebar); color: var(--color-sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0; transition: width .15s ease; overflow: hidden; }
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-toggle { flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,.08); color: var(--color-sidebar-text); font-size: 14px; line-height: 1; }
.sidebar-toggle:hover { background: rgba(255,255,255,.18); }
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; display: inline-block; }
.sidebar-header h2 { font-size: 18px; color: #fff; }
.sidebar-header p { font-size: 12px; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { padding: 10px 20px; cursor: pointer; font-size: 14px; display: flex; gap: 10px; }
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: var(--color-primary); color: #fff; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.main-content { flex: 1; padding: 28px 32px; overflow-x: auto; transition: padding-right .15s ease; }

/* Sānjoslas sakļaušana */
.app-layout.sidebar-collapsed .sidebar { width: 56px; }
.app-layout.sidebar-collapsed .sidebar-brand,
.app-layout.sidebar-collapsed .nav-label { display: none; }
.app-layout.sidebar-collapsed .sidebar-header { justify-content: center; padding: 18px 0; }
.app-layout.sidebar-collapsed .nav-item { justify-content: center; padding: 12px 0; }
.app-layout.sidebar-collapsed .sidebar-footer { padding: 12px 6px; }
.app-layout.sidebar-collapsed .sidebar-footer .btn { padding: 8px 0; }

/* Claude panelis — fiksēts labajā pusē, pabīda galveno saturu */
.app-layout.chat-open .main-content { padding-right: 412px; }
.chat-panel.chat-panel-docked { position: fixed; top: 0; right: 0; width: 380px; height: 100vh;
  margin: 0; border-radius: 0; border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 16px rgba(0,0,0,.08); z-index: 40; }
.chat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.chat-close { cursor: pointer; color: var(--color-muted); font-size: 16px; line-height: 1; }
.chat-close:hover { color: var(--color-text); }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 24px; }
.page-header p { color: var(--color-muted); margin-top: 4px; }

/* Cards */
.card { background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-weight: 600; margin-bottom: 12px; }

/* Requirements grid */
.req-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--color-surface); }
.req-table th, .req-table td { border: 1px solid var(--color-border); padding: 6px 8px; text-align: left; vertical-align: top; }
.req-table th { background: #f1f5f9; font-weight: 600; position: sticky; top: 0; font-size: 12px; }
.req-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.req-row-heading td { background: #e2e8f0; font-weight: 700; }
.grid-totals-row th { position: static; background: #eef2ff; font-weight: 600; color: #3730a3; border-top: 2px solid #c7d2fe; }
.grid-totals-row th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid-totals-row .grid-totals-label { text-align: right; font-weight: 700; color: #1e1b4b; }
.req-row-definition td { background: #f8fafc; color: var(--color-muted); font-style: italic; }
.cell-input { width: 56px; border: 1px solid transparent; background: transparent; padding: 3px 4px;
  text-align: right; border-radius: 4px; font-size: 13px; }
.cell-input:hover { border-color: var(--color-border); }
.cell-input.manual { background: #fef9c3; font-weight: 600; }
.status-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.status-estimated { background: #dcfce7; color: #166534; }
.status-unestimated { background: #fef3c7; color: #92400e; }
.totals-bar { display: flex; gap: 24px; padding: 12px 16px; background: #eff6ff;
  border: 1px solid #bfdbfe; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.totals-bar b { font-variant-numeric: tabular-nums; }

/* Requirements view modes */
.req-modes { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.req-overview td { vertical-align: top; }
.req-desc { font-size: 12px; color: var(--color-muted); margin-top: 2px; max-width: 680px; line-height: 1.45; }
.req-comment { font-size: 12px; color: #92400e; margin-top: 5px; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; padding: 3px 8px; display: inline-block; max-width: 680px; }

/* Focus estimator */
.focus-wrap { max-width: 760px; }
.focus-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.focus-progress { font-size: 13px; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.focus-card { padding: 22px 24px; }
.focus-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.focus-section { font-size: 11px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.focus-title { font-size: 18px; line-height: 1.35; }
.focus-id { color: var(--color-primary); font-weight: 700; margin-right: 6px; }
.focus-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 12px 0; }
.focus-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.focus-meta-label { font-size: 12px; color: var(--color-muted); font-weight: 600; }
.focus-meta-info { display: flex; flex-wrap: wrap; gap: 6px; }
.focus-meta .tag-editor { margin-top: 0; }
.tag { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: #eef2ff; color: #3730a3; }
.tag-muted { background: var(--color-bg); color: var(--color-muted); }
.focus-desc { font-size: 14px; line-height: 1.55; margin: 8px 0 4px; }
.focus-fulltext { font-size: 14px; line-height: 1.6; margin: 12px 0; white-space: pre-line; color: var(--color-text); }
.focus-orig { margin: 10px 0; font-size: 13px; }
.focus-orig summary { cursor: pointer; color: var(--color-muted); }
.focus-orig p { margin-top: 6px; color: var(--color-muted); background: var(--color-bg); padding: 8px 10px; border-radius: 6px; }
.focus-roles { margin-top: 18px; }
.focus-roles-title { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.focus-roles-table { max-width: 440px; }
.focus-roles-table .cell-input { border-color: var(--color-border); width: 72px; }
.focus-roles-total td { background: #f1f5f9; }
.focus-comment { margin-top: 18px; }
.focus-comment label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.focus-breakdown { margin-top: 12px; padding: 10px 14px; background: var(--color-bg); border-radius: var(--radius); font-size: 13px; line-height: 1.7; }
.cmark-q { color: var(--color-primary); font-weight: 600; }
.cmark-imp { color: var(--color-danger); font-weight: 600; }
.comment-preview { margin-top: 6px; padding: 6px 10px; background: var(--color-bg); border-radius: 6px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.clog { display: flex; flex-direction: column; gap: 8px; }
.clog-compact { gap: 5px; }
.clog-empty { color: var(--color-muted); font-size: 12px; }
.clog-comment { background: var(--color-bg); border-radius: 6px; padding: 6px 9px; }
.clog-meta { font-size: 11px; color: var(--color-muted); display: flex; align-items: center; gap: 6px; }
.clog-time { font-variant-numeric: tabular-nums; }
.clog-del { margin-left: auto; cursor: pointer; color: var(--color-danger); font-weight: 600; }
.clog-text { font-size: 13px; line-height: 1.5; white-space: pre-wrap; margin-top: 2px; }
.clog-change { font-size: 12px; color: var(--color-muted); border-left: 3px solid var(--color-primary); padding: 3px 0 3px 8px; }
.clog-more { font-size: 11px; color: var(--color-muted); }
.clog-add { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.clog-add textarea { width: 100%; resize: vertical; }
.clog-add .btn { align-self: flex-start; }
.overview-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-start; margin-bottom: 10px; }
.tag-filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.tag-filter-label { font-size: 12px; color: var(--color-muted); white-space: nowrap; }

/* Tegu redaktors (čipi + pievienošana) */
.tag-editor { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 6px; }
.tag-editor-compact { margin-top: 4px; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; padding-right: 4px; }
.tag-chip-x { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  border-radius: 50%; background: rgba(55, 48, 163, .12); color: #3730a3; font-size: 12px; font-weight: 700;
  line-height: 1; cursor: pointer; }
.tag-chip-x:hover { background: var(--color-danger); color: #fff; }
.tag-add-btn { cursor: pointer; background: var(--color-bg); color: var(--color-muted); border: 1px dashed var(--color-border); }
.tag-add-btn:hover { color: var(--color-primary); border-color: var(--color-primary); }
.tag-add input { font-size: 11px; padding: 2px 6px; border: 1px solid var(--color-primary); border-radius: 999px; width: 120px; }

/* Tegu filtra josla (Pārskats / Pilns režģis) */
.tag-filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 10px;
  padding: 8px 12px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); }
.tag-filter-empty { font-size: 12px; color: var(--color-muted); font-style: italic; }

/* Saistības / links */
.links-inline { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.link-chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.focus-links { margin-top: 18px; padding: 14px 16px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); }
.focus-link-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px dashed var(--color-border); }
.focus-link-row:last-child { border-bottom: none; }
.link-jump { background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: 13px; font-weight: 500; padding: 0; text-align: left; }
.link-jump:hover { text-decoration: underline; }
.focus-link-note { flex-basis: 100%; font-size: 12px; color: var(--color-muted); margin-left: 2px; }

/* Nepilnīga satura paziņojums (tabula/attēls oriģinālā) */
.content-notice { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; padding: 10px 14px;
  background: #fffbeb; border: 1px solid var(--color-warn); border-left-width: 4px; border-radius: var(--radius);
  color: #92400e; font-size: 13px; line-height: 1.5; white-space: normal; }
.content-notice-icon { flex-shrink: 0; }
.tag-warn { background: #fef3c7; color: #92400e; }
.badge-warn { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 600; vertical-align: middle; }

/* Definitions side panel */
.defs-panel { position: fixed; top: 0; right: 0; width: 360px; height: 100vh; background: var(--color-surface);
  border-left: 1px solid var(--color-border); box-shadow: -4px 0 16px rgba(0,0,0,.08); padding: 20px;
  overflow-y: auto; z-index: 50; }
.defs-panel h3 { margin-bottom: 12px; }
.def-item { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.def-item b { display: block; }

/* Chat panel */
.chat-panel { display: flex; flex-direction: column; height: 70vh; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; background: var(--color-bg); border-radius: var(--radius); }
.chat-msg { margin-bottom: 12px; padding: 10px 12px; border-radius: var(--radius); max-width: 85%; font-size: 14px; white-space: pre-wrap; }
.chat-user { background: var(--color-primary); color: #fff; margin-left: auto; }
.chat-assistant { background: var(--color-surface); border: 1px solid var(--color-border); }
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

/* Novērtējuma pieraksti */
.notes-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.notes-editor { min-height: 440px; max-height: 70vh; overflow-y: auto; padding: 16px 18px;
  border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface);
  font-size: 14px; line-height: 1.6; outline: none; }
.notes-editor:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.notes-editor:empty:before { content: attr(data-placeholder); color: var(--color-muted); }
.notes-editor h3 { font-size: 16px; margin: 14px 0 6px; }
.notes-editor ul, .notes-editor ol { margin: 6px 0 6px 24px; }
.notes-editor p { margin: 0 0 8px; }
.notes-editor:focus:before { content: none; }


/* ── Iepirkumu tabula ─────────────────────────────────────────────────────── */
.iep-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.iep-table th {
  text-align: left; padding: 8px 10px; white-space: nowrap;
  border-bottom: 2px solid var(--color-border, #e2e8f0);
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--color-muted, #64748b); position: sticky; top: 0; background: #fff; z-index: 1;
}
.iep-table td { padding: 7px 10px; border-bottom: 1px solid var(--color-border, #eef2f7); vertical-align: top; }
.iep-table tbody tr:hover { background: #f8fafc; }
.iep-table a { color: var(--color-primary, #2563eb); text-decoration: none; }
.iep-table a:hover { text-decoration: underline; }


/* ── Iepirkuma detaļu modālis ─────────────────────────────────────────────── */
.iep-modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.iep-modal {
  background: #fff; border-radius: 10px; width: 100%; max-width: 760px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
}
.iep-modal-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--color-border, #e2e8f0);
  position: sticky; top: 0; background: #fff; border-radius: 10px 10px 0 0; z-index: 2;
}
.iep-modal-head h2 { word-break: break-word; }
.iep-modal-body { padding: 16px 20px; }
.iep-modal-body .card { margin-bottom: 12px; }
.iep-modal-body .card:last-child { margin-bottom: 0; }
