/* Rexlucris CGP: temno modra #010d1e + zlata #ac9a7e + bela; font Barlow */
:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --border: #e8e5df;
  --text: #17203a;
  --muted: #74706a;
  --navy: #010d1e;
  --navy-2: #0d1b33;
  --navy-3: #16264a;
  --gold: #ac9a7e;
  --gold-dark: #8f7a54;
  --gold-soft: #f5f1e9;
  --primary: var(--navy-2);
  --green: #17936a;
  --orange: #d8821a;
  --red: #c34848;
  --sidebar-text: #a9b0c2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(1,13,30,.05), 0 6px 24px rgba(1,13,30,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.8px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-dark); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; background: var(--navy);
  color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
  border-right: 1px solid rgba(172,154,126,.18);
}
.sidebar .logo { padding: 22px 18px 16px; text-align: center; }
.sidebar .logo img { width: 100%; max-width: 178px; display: block; margin: 0 auto; }
.sidebar .logo small {
  display: block; color: var(--gold); font-size: 10.5px; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase; margin-top: 9px;
}
.sidebar nav { flex: 1; padding: 10px 12px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px; margin: 3px 0;
  color: var(--sidebar-text); border-radius: 10px; font-weight: 500; font-size: 14px;
  transition: background .12s, color .12s;
}
.sidebar nav a:hover { background: rgba(172,154,126,.12); text-decoration: none; color: #fff; }
.sidebar nav a.active {
  background: linear-gradient(90deg, var(--gold), #c5b494); color: var(--navy);
  font-weight: 600; box-shadow: 0 4px 14px rgba(172,154,126,.35);
}
.sidebar .user {
  padding: 14px 20px; border-top: 1px solid rgba(172,154,126,.18); font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar .user button { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 12.5px; font-family: inherit; }
.sidebar .user button:hover { color: var(--gold); }

.main { flex: 1; margin-left: 236px; padding: 28px 36px 70px; max-width: 1420px; }
.page-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-title h1 { font-size: 24px; margin: 0; letter-spacing: -.2px; color: var(--navy); font-weight: 700; }
.page-title .crumb { color: var(--muted); font-size: 13px; margin-top: 4px; max-width: 720px; }

/* ---------- Components ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px; }
.card h2 { font-size: 15.5px; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--navy); }
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.grid > .full { grid-column: 1 / -1; }

.stat { border-top: 3px solid var(--gold); }
.stat .num { font-size: 28px; font-weight: 700; color: var(--navy); letter-spacing: -.5px; }
.stat .lbl { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--gold-dark); padding: 8px 10px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--gold-soft); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .13s; font-family: inherit;
}
.btn:hover { border-color: var(--gold); color: var(--gold-dark); background: var(--gold-soft); }
.btn.primary {
  background: linear-gradient(135deg, var(--navy-2), var(--navy-3)); border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px rgba(1,13,30,.25);
}
.btn.primary:hover { background: linear-gradient(135deg, var(--navy-3), #1d3160); color: #fff; border-color: var(--gold); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: #fdf2f2; color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.8px; font-weight: 600; white-space: nowrap; }
.badge.gray   { background: #eeece7; color: #6a655c; }
.badge.blue   { background: #e6ebf5; color: var(--navy-2); }
.badge.green  { background: #e0f5ec; color: var(--green); }
.badge.orange { background: #fdf1dd; color: #b06f10; }
.badge.red    { background: #fdeaea; color: var(--red); }
.badge.purple { background: var(--gold-soft); color: var(--gold-dark); }

input, select, textarea {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(172,154,126,.20); }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 13px 0 5px; letter-spacing: .2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }

.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 13.5px; line-height: 1.6; }

/* ---------- Combobox ---------- */
.combo { position: relative; }
.combo input { padding-right: 34px; }
.combo .combo-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 11px; }
.combo .combo-clear { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px; width: auto; }
.combo .combo-clear:hover { color: var(--red); }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 40px rgba(1,13,30,.16);
  max-height: 330px; overflow-y: auto; z-index: 60; padding: 5px;
}
.combo-item { padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.combo-item:hover, .combo-item.active { background: var(--gold-soft); }
.combo-item .ttl { font-weight: 600; font-size: 13.5px; }
.combo-item .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.combo-hint { padding: 8px 12px; font-size: 12px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(1,13,30,.55); backdrop-filter: blur(2px); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 760px; padding: 26px 30px; box-shadow: 0 18px 60px rgba(0,0,0,.3); animation: modalin .16s ease-out; }
.modal.wide { max-width: 1000px; }
@keyframes modalin { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Login ---------- */
.login-wrap { flex: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #010d1e 0%, #0d1f42 60%, #14284f 100%); }
.login-box { background: #fff; border-radius: 18px; width: 400px; box-shadow: 0 24px 70px rgba(0,0,0,.45); overflow: hidden; }
.login-logo { background: var(--navy); padding: 30px 34px 26px; }
.login-logo img { width: 100%; display: block; }
.login-form { padding: 24px 34px 32px; }
.login-form p { color: var(--gold-dark); margin: 0 0 14px; font-size: 12px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; text-align: center; }
.login-box .error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-box button { width: 100%; margin-top: 18px; padding: 11px; font-size: 15px; justify-content: center; }

/* ---------- Chat ---------- */
.chat-box { display: flex; flex-direction: column; height: 480px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 6px 2px; }
.msg { max-width: 84%; margin: 7px 0; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; line-height: 1.45; font-size: 13.8px; }
.msg.user { background: linear-gradient(135deg, var(--navy-2), var(--navy-3)); color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.msg.assistant { background: var(--gold-soft); border-bottom-left-radius: 5px; }
.msg .meta { font-size: 11px; opacity: .65; margin-top: 5px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.chat-input textarea { min-height: 44px; max-height: 140px; }
.mic-btn.recording { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(195,72,72,.5); } 70% { box-shadow: 0 0 0 10px rgba(195,72,72,0); } 100% { box-shadow: 0 0 0 0 rgba(195,72,72,0); } }

/* ---------- Job log / preview ---------- */
pre.log { background: var(--navy); color: #c8d4ea; padding: 14px 16px; border-radius: 12px; font-size: 12px; overflow-x: auto; max-height: 420px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.doc-preview { border: 1px solid var(--border); border-radius: 12px; padding: 24px 30px; background: #fff; max-height: 640px; overflow-y: auto; }
.doc-preview table { border: 1px solid #ccc; margin: 10px 0; }
.doc-preview td, .doc-preview th { border: 1px solid #ccc; padding: 4px 8px; }
.markdown-body { line-height: 1.55; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 14px 0 6px; }
.markdown-body ul { margin: 6px 0; padding-left: 22px; }

/* ---------- Misc ---------- */
.progress-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item .name { flex: 1; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-input { max-width: 320px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff;
  padding: 12px 20px; border-radius: 12px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.3);
  animation: fadein .2s; max-width: 420px; border-left: 3px solid var(--gold);
}
.toast.err { background: var(--red); border-left-color: #fff; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }
.rok-warn { color: var(--red); font-weight: 700; }
.rok-soon { color: var(--orange); font-weight: 600; }
.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: all .15s; font-size: 13px; }
.dropzone:hover, .dropzone.drag { border-color: var(--gold); color: var(--gold-dark); background: var(--gold-soft); }
