:root {
  --bg: #0f1419;
  --bg2: #171d24;
  --bg3: #1f2731;
  --border: #2c3947;
  --text: #dbe4ee;
  --muted: #8296ab;
  --accent: #4da3ff;
  --accent-dim: #1d3a5c;
  --mark: #ffd866;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text);
  padding: 7px 14px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.ghost { background: transparent; }
button:hover { filter: brightness(1.15); }
input, select {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
mark { background: var(--mark); color: #1a1a1a; padding: 0 2px; border-radius: 2px; }
.error { color: #ff7b72; min-height: 1.2em; margin-top: 8px; font-size: 13px; }

/* ---------- login ---------- */
#login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 100;
}
.login-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 40px; width: 360px; display: flex; flex-direction: column; gap: 12px;
  text-align: center;
}
.login-card h1 { margin: 0; font-size: 21px; }
.login-card p { margin: 0; color: var(--muted); }

/* ---------- header ---------- */
#panel { display: flex; flex-direction: column; height: 100vh; }
header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--bg2);
  flex: none;
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
#search-form { display: flex; gap: 8px; flex: 1; max-width: 720px; }
#search-form input[type=search] { flex: 1; }
.stats { color: var(--muted); font-size: 12px; flex: 1; text-align: right; }

/* ---------- filtry ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  padding: 12px 18px; background: var(--bg2); border-bottom: 1px solid var(--border);
  flex: none;
}
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters label.check { flex-direction: row; align-items: center; font-size: 13px; color: var(--text); }

/* ---------- 3 panele ---------- */
#layout {
  display: grid; grid-template-columns: 230px 400px 1fr;
  flex: 1; min-height: 0;
}

/* sidebar */
#sidebar {
  border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 0;
  background: var(--bg2);
}
.side-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 10px 14px 4px;
}
.nav-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 14px; cursor: pointer; font-size: 13px;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg3); }
.nav-item.active { background: var(--accent-dim); color: #cfe6ff; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { color: var(--muted); font-size: 11px; flex: none; }
.nav-item.depth1 { padding-left: 26px; }
.nav-item.depth2 { padding-left: 38px; }
.nav-item.depth3 { padding-left: 50px; }

/* lista wiadomosci */
#list-pane {
  border-right: 1px solid var(--border); overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column;
}
#list-meta { color: var(--muted); font-size: 12px; padding: 10px 14px 4px; flex: none; }
#message-list { flex: none; }
.msg {
  padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.msg:hover { background: var(--bg3); }
.msg.active { background: var(--accent-dim); }
.msg .row1 { display: flex; justify-content: space-between; gap: 10px; }
.msg .from { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .date { color: var(--muted); font-size: 11.5px; flex: none; }
.msg .subject { font-size: 13px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .subject .clip { margin-left: 6px; }
.msg .snippet { color: var(--muted); font-size: 12px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#load-more { margin: 12px 14px; flex: none; }

/* panel czytania */
#read-pane { overflow-y: auto; min-height: 0; padding: 18px 24px; }
.read-empty {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; font-size: 15px;
}
#read-content h2 { margin: 0 0 10px; font-size: 18px; }
table.headers { border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
table.headers td { padding: 1px 12px 1px 0; vertical-align: top; }
table.headers td:first-child { color: var(--muted); white-space: nowrap; }
.atts { margin: 8px 0 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-size: 12.5px; color: var(--text); text-decoration: none;
}
.att-chip:hover { border-color: var(--accent); }
.att-chip .size { color: var(--muted); }
.view-tabs { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; }
.tab { padding: 4px 14px; border-radius: 20px; font-size: 12.5px; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.html-note { color: var(--muted); font-size: 11.5px; }
.body-text {
  white-space: pre-wrap; word-wrap: break-word; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 10px; padding: 16px;
  font-size: 13.5px;
}
.body-html {
  width: 100%; height: calc(100vh - 320px); min-height: 300px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
}

/* lista: zajawka zamiast pustego tematu (czaty Teams) */
.preview-subject { color: var(--muted); font-weight: 400; font-style: italic; }

/* widok watku / rozmowy */
#thread-meta { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.thread-msg {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px; cursor: pointer;
}
.thread-msg:hover { border-color: var(--accent); }
.thread-msg.current { border-color: var(--accent); background: var(--accent-dim); }
.thread-msg.chat { border-left: 3px solid #7b6cff; }
.thread-msg .row1 { display: flex; justify-content: space-between; gap: 10px; }
.thread-msg .from { font-weight: 600; font-size: 13px; }
.thread-msg .date { color: var(--muted); font-size: 11.5px; }
.thread-msg .body-preview {
  font-size: 13px; color: #b7c5d3; margin-top: 3px; white-space: pre-wrap;
}
.thread-msg .atts-mini { color: var(--muted); font-size: 12px; margin-top: 4px; }
