/* Přemyslovské stráně · Admin
   Brand color: #988b63 (matches main site).
   Visual language: clean, premium, minimal noise.
*/

:root {
  --brand: #988b63;
  --brand-dark: #766b4b;
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #2a2a2a;
  --muted: #6b6b6b;
  --border: #e6e3dc;
  --danger: #b03a3a;
  --success: #4a7a3a;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand a {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}
.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}
.tabs a {
  padding: 8px 16px;
  color: var(--muted);
  border-radius: var(--radius);
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}
.tabs a:hover { background: var(--bg); text-decoration: none; }
.tabs a.active { color: var(--brand); background: rgba(152,139,99,0.08); }
.user-menu { display: flex; gap: 12px; align-items: center; }
.who { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  background: var(--brand);
  color: white;
  font-size: 11px;
  border-radius: 10px;
  font-style: normal;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- content ---------- */
.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: var(--bg); border-color: var(--brand); }
.btn.primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: white; }
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
}
.btn-link:hover { color: var(--brand); }

/* ---------- forms ---------- */
input[type=text], input[type=password], input[type=email] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: white;
  width: 100%;
}
input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label { display: block; margin-bottom: 12px; }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label.checkbox { display: flex; align-items: center; gap: 8px; }
label.checkbox input { width: auto; }
.form-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
.form-inline label { margin-bottom: 0; flex: 1; min-width: 180px; }

/* ---------- alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert.error { background: rgba(176,58,58,0.08); color: var(--danger); border: 1px solid rgba(176,58,58,0.2); }
.alert.success { background: rgba(74,122,58,0.08); color: var(--success); border: 1px solid rgba(74,122,58,0.2); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--bg) 0%, #f3f0e8 100%);
}
.login-card {
  background: var(--surface);
  padding: 40px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .muted { margin: 0 0 24px; font-size: 13px; }
.login-card button { width: 100%; margin-top: 8px; padding: 10px; font-size: 14px; }

/* ---------- dashboard ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.card {
  display: block;
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text);
  transition: transform 0.1s, border-color 0.1s;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.card h2 { color: var(--brand); margin-bottom: 6px; }
.card p { color: var(--muted); margin: 0; font-size: 13px; }

/* ---------- drive ---------- */
.breadcrumbs { padding: 12px 0; font-size: 14px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs .sep { color: var(--border); margin: 0 6px; }
.breadcrumbs .current { color: var(--text); font-weight: 500; }

.drive-toolbar { display: flex; gap: 8px; margin-bottom: 16px; }

#mkdir-form { display: flex; gap: 8px; margin-bottom: 16px; }

.dropzone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s;
  min-height: 200px;
}
.dropzone.drag-over {
  background: rgba(152,139,99,0.06);
  border-color: var(--brand);
  border-style: solid;
}

.drive-table, .data-table {
  width: 100%;
  border-collapse: collapse;
}
.drive-table th, .drive-table td, .data-table th, .data-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.drive-table th, .data-table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.drive-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.entry { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; }
.entry.dir { font-weight: 500; }
.entry.file { color: var(--text); }
.entry-icon { display: inline-block; width: 32px; text-align: center; font-size: 18px; flex-shrink: 0; }
.entry-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: #f4f0e6;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.entry-name { word-break: break-all; }

.row-actions { text-align: right; width: 60px; }
.menu summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius);
  color: var(--muted);
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--bg); }
.menu-pop {
  position: absolute;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 220px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-pop form { display: flex; gap: 4px; align-items: center; }
.menu-pop form input { flex: 1; padding: 4px 8px; font-size: 12px; }

.upload-progress {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.upload-progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.upload-progress-bar #upload-bar {
  height: 100%;
  background: var(--brand);
  width: 0;
  transition: width 0.2s;
}
#upload-status { font-size: 13px; color: var(--muted); }

/* ---------- users ---------- */
.add-user { margin-top: 24px; }
.add-user summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
}
.add-user[open] summary { margin-bottom: 16px; }

/* ---------- email ---------- */
.email-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}
.email-tabs { display: flex; gap: 4px; }
.email-tabs a {
  padding: 6px 14px;
  color: var(--muted);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
}
.email-tabs a.active { color: var(--brand); background: rgba(152,139,99,0.08); }
.email-tabs a:hover { background: var(--bg); text-decoration: none; }
.badge.unread {
  background: var(--brand);
  color: white;
  font-size: 11px;
  padding: 1px 7px;
  margin-left: 4px;
}
.badge.accounting {
  background: rgba(74,122,58,0.12);
  color: var(--success);
  padding: 1px 8px;
  font-size: 11px;
  margin-left: 6px;
  font-weight: 500;
}

.email-list {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: collapse;
}
.email-list tr { border-bottom: 1px solid var(--border); }
.email-list tr:last-child { border-bottom: none; }
.email-list tr:hover { background: var(--bg); }
.email-list tr.unread .from, .email-list tr.unread .subject { font-weight: 600; color: var(--text); }
.email-list td { padding: 0; }
.email-list td.center { text-align: center; padding: 40px; }
.email-row {
  display: grid;
  grid-template-columns: 200px 1fr 100px;
  gap: 16px;
  padding: 12px 16px;
  align-items: center;
  color: var(--text);
}
.email-row:hover { text-decoration: none; }
.email-row .from { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-row .subject { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-row .ts { font-size: 12px; text-align: right; }
.attach-icon { margin-left: 6px; }

.email-view-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
  flex-wrap: wrap;
}
.email-view-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.email-view-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.email-view-meta h1 { font-size: 20px; margin-bottom: 16px; }
.meta-table { font-size: 13px; }
.meta-table th { text-align: right; color: var(--muted); padding: 2px 12px 2px 0; font-weight: 400; }
.meta-table td { padding: 2px 0; }

.attachments {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 16px;
}
.attachments h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 500; }
.attachments ul { list-style: none; padding: 0; margin: 0; }
.attachments li { padding: 4px 0; }

.email-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  overflow: auto;
}
.body-text {
  font-family: -apple-system, sans-serif;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  background: none;
}
.body-html { width: 100%; min-height: 400px; border: none; }

.email-compose .compose-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.compose-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.forward-attachments {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.forward-attachments legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.compose-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ---------- accounting (email view) ---------- */
.accounting-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
}
.accounting-section h2 { font-size: 16px; margin-bottom: 12px; color: var(--brand-dark); }
.accounting-section h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.acct-existing { margin-bottom: 24px; }
.acct-form summary { cursor: pointer; list-style: none; display: inline-block; }
.acct-form summary::-webkit-details-marker { display: none; }
.acct-form[open] summary { margin-bottom: 16px; }
.acct-form-body { display: flex; flex-direction: column; gap: 12px; }
.acct-row { display: grid; grid-template-columns: 100px 100px 1fr 100px; gap: 12px; }
.acct-cottages {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.acct-cottages legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.acct-cottages label { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.acct-cottages label input { width: auto; }
.acct-cottages p { margin: 8px 0 0; }
.acct-form-body select, .acct-form-body input { width: 100%; }

/* ---------- uctovani ---------- */
.uctovani .page-header,
.uctovani-detail .page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 16px;
}
.uctovani .page-actions { display: flex; gap: 12px; align-items: center; }
.year-picker label { display: flex; gap: 8px; align-items: center; margin: 0; font-size: 13px; color: var(--muted); }
.year-picker select { padding: 6px 12px; }
.import-form summary { cursor: pointer; list-style: none; display: inline-block; }
.import-form summary::-webkit-details-marker { display: none; }
.import-form[open] summary { margin-bottom: 16px; }
.import-body {
  position: absolute;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  width: 320px;
  z-index: 10;
}

.overview-tables h3 {
  margin: 24px 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.uctovani-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.uctovani-table th, .uctovani-table td {
  padding: 10px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.uctovani-table th:first-child, .uctovani-table td:first-child { text-align: left; }
.uctovani-table th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.uctovani-table tr:last-child td { border-bottom: none; }
.uctovani-table .balance { font-variant-numeric: tabular-nums; }
.uctovani-table .balance.negative { color: var(--danger); }
.uctovani-table .balance.positive { color: var(--success); }
.uctovani-table .balance.total { font-weight: 600; border-left: 1px solid var(--border); }
.uctovani-table .balance a { color: inherit; }
.uctovani-table .balance a:hover { text-decoration: underline; }
.uctovani-table .total-row td { background: var(--bg); font-weight: 500; }

.uctovani-detail .amount { font-variant-numeric: tabular-nums; text-align: right; }
.uctovani-detail .amount.included { color: var(--text); }
.uctovani-detail .amount.excluded { color: var(--muted); text-decoration: line-through; }
.uctovani-detail .amount.expense { color: var(--danger); }
.uctovani-detail tr.muted { color: var(--muted); }
.uctovani-detail tr.muted td { color: var(--muted); }
.uctovani-detail tr.pending td { background: rgba(152,139,99,0.04); }
.status-p { color: var(--success); font-weight: 600; }
.status-s { color: var(--muted); text-decoration: line-through; }
.status-w { color: var(--muted); font-style: italic; }

/* ---------- wiki ---------- */
.wiki-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: flex-start;
}
.wiki-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 16px;
}
.wiki-sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.wiki-sidebar-header h2 { font-size: 12px; margin: 0; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 500; }
.wiki-sidebar-header .btn { font-size: 12px; padding: 4px 10px; }
.wiki-page-list { list-style: none; padding: 0; margin: 0; }
.wiki-page-list li { margin: 0; }
.wiki-page-list a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  border-radius: var(--radius);
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
}
.wiki-page-list a:hover { background: var(--bg); text-decoration: none; }
.wiki-page-list a.active { background: rgba(152,139,99,0.08); color: var(--brand); font-weight: 500; }

.wiki-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  min-height: 60vh;
}
.wiki-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
  gap: 12px;
}
.wiki-page-header h1 { font-size: 24px; margin: 0; }
.wiki-actions { display: flex; gap: 8px; align-items: flex-start; }
.wiki-meta { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }

/* Markdown rendered body */
.markdown { line-height: 1.65; font-size: 15px; }
.markdown h1 { font-size: 22px; margin: 28px 0 12px; }
.markdown h2 { font-size: 18px; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 16px; margin: 20px 0 8px; }
.markdown p { margin: 8px 0 12px; }
.markdown ul, .markdown ol { padding-left: 28px; margin: 8px 0 12px; }
.markdown li { margin: 4px 0; }
.markdown li.task-todo, .markdown li.task-done { list-style: none; margin-left: -22px; }
.markdown li.task-done { color: var(--muted); text-decoration: line-through; }
.markdown li.task-todo input, .markdown li.task-done input { margin-right: 6px; vertical-align: middle; }
.markdown a { color: var(--brand-dark); }
.markdown code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.markdown pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  overflow: auto;
  font-size: 13px;
}
.markdown pre code { background: none; padding: 0; }
.markdown blockquote {
  border-left: 3px solid var(--brand);
  padding: 4px 16px;
  margin: 12px 0;
  color: var(--muted);
  background: rgba(152,139,99,0.04);
}
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.markdown table { border-collapse: collapse; margin: 12px 0; }
.markdown table th, .markdown table td { padding: 6px 12px; border: 1px solid var(--border); }
.markdown table th { background: var(--bg); }
.markdown img { max-width: 100%; height: auto; }

/* Wiki editing */
.wiki-edit-form { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.wiki-edit-form textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
.wiki-edit-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.wiki-md-help summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
}
.wiki-md-help summary::-webkit-details-marker { display: none; }
.wiki-md-help-pop {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}
.wiki-md-help-pop code {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text);
}

.wiki-empty { text-align: center; padding: 60px 24px; }
.wiki-empty h1 { font-size: 28px; margin-bottom: 12px; }
.wiki-empty .muted { font-size: 14px; margin-bottom: 24px; }

/* Autosave indicator */
.wiki-edit-status { display: flex; gap: 12px; align-items: center; }
.autosave-indicator {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: background 0.2s, color 0.2s;
}
.autosave-indicator.editing { background: rgba(152,139,99,0.10); color: var(--brand-dark); }
.autosave-indicator.saving { background: rgba(152,139,99,0.18); color: var(--brand-dark); }
.autosave-indicator.saved { background: rgba(74,122,58,0.10); color: var(--success); }
.autosave-indicator.error { background: rgba(176,58,58,0.10); color: var(--danger); }

/* Version history table */
.wiki-history tr.current td { background: rgba(152,139,99,0.04); }
.wiki-history tr.current .badge { background: var(--brand); color: white; font-size: 11px; padding: 1px 8px; margin-left: 6px; }

.alert.info {
  background: rgba(74,108,140,0.08);
  color: #406480;
  border: 1px solid rgba(74,108,140,0.2);
  padding: 12px 16px;
  border-radius: var(--radius);
}

/* ---------- statistiky ---------- */

.stats h1 { margin-bottom: 16px; }
.stats h2 { margin-top: 32px; margin-bottom: 12px; font-size: 18px; font-weight: 600; }

.stats-toolbar {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
  margin: 24px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}
.filter-group { display: inline-flex; align-items: center; gap: 6px; }
.filter-label { font-size: 13px; color: var(--muted); margin-right: 4px; }

.stats-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}
.kpi {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.kpi-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--brand-dark);
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-label { font-size: 13px; color: var(--muted); }

.bar-chart {
  display: grid;
  grid-template-columns: repeat(var(--bar-count, 30), 1fr);
  gap: 2px;
  align-items: end;
  height: 260px;
  padding: 16px 8px 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
}
.bar-col {
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  position: relative;
  height: 100%;
  min-width: 0;
}
.bar-fill {
  width: 80%;
  max-width: 28px;
  background: var(--brand);
  border-radius: 2px 2px 0 0;
  min-height: 1px;
  transition: background 0.15s;
}
.bar-col:hover .bar-fill { background: var(--brand-dark); }
.bar-count {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.bar-label {
  position: absolute;
  bottom: -20px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: center top;
}

.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Statistiky: klikací řádek v sources tabulce — filtr grafu */
.sources-table tbody tr.sources-row {
  cursor: pointer;
  transition: background 0.1s;
}
.sources-table tbody tr.sources-row:hover {
  background: var(--bg);
}
.sources-table tbody tr.sources-row.active {
  background: rgba(152, 139, 99, 0.12);
  border-left: 3px solid var(--brand);
}
.sources-table tbody tr.sources-row.active td:first-child {
  padding-left: calc(12px - 3px);  /* offset border */
}
.sources-table tbody tr.reset-row {
  font-style: italic;
}
.sources-table tbody tr.bot-row {
  cursor: default;
  opacity: 0.6;
  font-style: italic;
  border-top: 1px dashed var(--border, #ddd);
}
.sources-table tbody tr.bot-row:hover {
  background: transparent;
}
.kpi-source-tag, .brand-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(152, 139, 99, 0.15);
  color: var(--brand-dark);
}
.brand-tag { font-size: 16px; padding: 4px 10px; }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .wiki-wrap { grid-template-columns: 1fr; }
  .wiki-sidebar { position: static; }
}

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .tabs { order: 3; flex-basis: 100%; }
  .content {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .drive-table th:nth-child(2), .drive-table td:nth-child(2) { display: none; }
  .form-inline label { flex-basis: 100%; }
}

/* =========================================================================
   Webmail F3 — thread-per-row inbox + thread accordion view
   ========================================================================= */

.email-toolbar .toolbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.email-toolbar .toolbar-actions .btn.small {
  min-width: 36px;
  text-align: center;
}
.inbox-address { margin: 0 0 12px; }

/* Inbox jako table — 4 sloupce, každý nowrap+ellipsis:
   Od (240px) | Subject (1fr 35%) | Náhled (1fr 65%) | Datum (130px) */
.thread-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--border);
  table-layout: fixed;
}
.thread-table .col-from    { width: 240px; }
.thread-table .col-subject { width: 35%; }
.thread-table .col-snippet { width: auto; }   /* zbytek prostoru */
.thread-table .col-ts      { width: 130px; }

.thread-table tr.thread-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.thread-table tr.thread-row:hover { background: var(--bg); }
.thread-table tr.thread-row.unread {
  background: rgba(152,139,99,0.04);
}
.thread-table tr.thread-row.unread .thread-from-cell,
.thread-table tr.thread-row.unread .thread-subject-cell {
  font-weight: 600;
}
.thread-table td {
  padding: 10px 12px;
  font-size: 14px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-from-cell    { color: var(--text); }
.thread-subject-cell { color: var(--text); }
.thread-snippet-cell {
  color: var(--muted);
  font-size: 13px;
}
.thread-count {
  color: var(--brand-dark);
  font-weight: 400;
  margin-left: 4px;
  font-size: 13px;
}
.thread-ts-cell {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.attach-icon { font-size: 12px; margin-left: 4px; }

/* ===== F6: Search + label filter + bulk akce ===== */

.email-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
  align-items: center;
}
.email-search-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  min-width: 250px;
}
.email-search-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--surface);
}
.email-search-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}

.label-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.label-chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--label-color, var(--border));
  color: var(--label-color, var(--text));
  background: rgba(255,255,255,0.5);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.label-chip.active {
  background: var(--label-color, var(--brand));
  color: white;
}
.label-chip.inline {
  margin-left: 6px;
  vertical-align: middle;
}
.label-chip.small {
  font-size: 10px;
  padding: 1px 6px;
}

/* Bulk: checkbox column + selection bar */
.thread-table .col-check { width: 36px; }
.thread-check-cell {
  text-align: center;
  cursor: default;
  padding: 0 !important;
}
.thread-check {
  cursor: pointer;
  width: 16px;
  height: 16px;
}
.selection-bar {
  position: sticky;
  top: 12px;
  display: none;
  background: var(--surface);
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 12px;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 10;
}
.selection-bar.visible { display: flex; }
.selection-count {
  font-weight: 600;
  margin-right: 8px;
  color: var(--brand-dark);
}

/* Label picker (thread view) */
details.label-picker {
  position: relative;
  display: inline-block;
}
details.label-picker summary {
  list-style: none;
  cursor: pointer;
}
details.label-picker summary::-webkit-details-marker { display: none; }
.label-picker-pop {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 200px;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 8px;
  z-index: 10;
}
.label-picker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  cursor: pointer;
}
.label-picker-item input { cursor: pointer; }

@media (max-width: 700px) {
  .email-filter-row { gap: 8px; }
  .email-search-form { width: 100%; }
  .selection-bar { padding: 10px; }
  .thread-table .col-check { width: 32px; }
  .label-picker-pop {
    /* Na mobilu drop dolů přes celou šířku */
    left: 0;
    right: auto;
    max-width: 100%;
  }
}

/* ===== Vlaječky (color flags per thread) ===== */

.flag-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
}
.flag-dot.inline { margin-right: 6px; }
.flag-dot[data-color="red"]    { background: #d93025; }
.flag-dot[data-color="orange"] { background: #e8710a; }
.flag-dot[data-color="yellow"] { background: #f9ab00; }
.flag-dot[data-color="green"]  { background: #188038; }
.flag-dot[data-color="blue"]   { background: #1967d2; }
.flag-dot[data-color="purple"] { background: #9334e6; }
.flag-dot[data-color="none"] {
  background: var(--surface);
  font-size: 10px;
  line-height: 10px;
  color: var(--muted);
  text-align: center;
}

details.flag-picker {
  position: relative;
  display: inline-block;
}
details.flag-picker summary {
  list-style: none;
  cursor: pointer;
}
details.flag-picker summary::-webkit-details-marker { display: none; }
.flag-picker-pop {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 11;
}
/* bulk-flag-pop: zachová default (left: 0) — když je bar nahoře, máme prostor doprava-dolů */
.flag-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.flag-btn:hover { border-color: var(--brand); background: var(--bg); }
.flag-btn .flag-dot { border: none; }

/* Save attachment to Drive (F8) */
.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 0;
}
.save-to-drive {
  position: relative;
}
.save-to-drive summary {
  list-style: none;
  cursor: pointer;
}
.save-to-drive summary::-webkit-details-marker { display: none; }
.save-to-drive-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  flex-wrap: wrap;
}
.save-to-drive-form input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.saved-marker { color: #4a7a3a; }

/* Banner "Načíst obrázky" v thread view (F7) */
.image-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin: 12px 0;
  background: #f5f1e8;
  border: 1px solid #c8b88c;
  border-radius: 6px;
  color: #5d4d2a;
  font-size: 13px;
  flex-wrap: wrap;
}

/* Autosave indikátor (compose, draft) */
.autosave-indicator {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  margin-left: 12px;
}
.autosave-indicator.editing { background: #fff4d6; border-color: #e7d398; color: #806a1c; }
.autosave-indicator.saving  { background: #d5e8ff; border-color: #a5c4e6; color: #1a4a85; }
.autosave-indicator.saved   { background: #e5f3d8; border-color: #b5d496; color: #355f1f; }
.autosave-indicator.error   { background: #fde0e0; border-color: #e69a9a; color: #802121; }

.thread-view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.thread-view-header .back-btn {
  font-size: 18px;
  line-height: 1;
  padding: 6px 12px;
  flex-shrink: 0;
}
.thread-title {
  flex: 1;
  font-size: 20px;
  margin: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-messages { list-style: none; padding: 0; margin: 0; }
.msg {
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 8px;
  background: var(--surface);
}
.msg details { padding: 0; }
.msg summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  user-select: none;
}
.msg summary::-webkit-details-marker { display: none; }
.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.msg-from {
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dir-badge.outbound {
  display: inline-block;
  color: var(--brand);
  font-weight: 600;
  margin-right: 4px;
}
.msg-ts { flex-shrink: 0; }
.msg-preview-collapsed {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-body-wrap { padding: 0 16px 16px; }
.msg-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.msg-attachments {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.attachments-list { list-style: none; padding: 0; margin: 4px 0 0; }
.attachments-list li { padding: 2px 0; }
.msg-html-frame {
  width: 100%;
  min-height: 80px;            /* fallback pokud JS auto-resize selže */
  height: 80px;                /* JS ji přepíše po načtení dle scrollHeight */
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  display: block;
}
.msg-plain {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  margin: 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

@media (max-width: 700px) {
  .email-toolbar { flex-direction: column; gap: 8px; align-items: stretch; }
  .toolbar-actions { justify-content: flex-end; }
  /* Mobile: vypustíme sloupec náhledu (nejmíň důležitý), zkrátíme Od */
  .thread-table { table-layout: fixed; }
  .thread-table .col-from    { width: 40%; }
  .thread-table .col-subject { width: auto; }
  .thread-table .col-snippet { display: none; }
  .thread-table .col-ts      { width: 80px; }
  .thread-snippet-cell { display: none; }
  .thread-table td { padding: 8px 8px; font-size: 13px; }
  .thread-ts-cell { font-size: 11px; }
  .thread-view-header { gap: 8px; }
  .thread-title { font-size: 16px; }
  .msg-html-frame { min-height: 100px; }
}
