:root {
  --accent: #4353b0;
  --accent-soft: #eef0fb;
  --ink: #1c2030;
  --muted: #6b7285;
  --line: #e4e6ee;
  --bg: #f7f8fb;
  --card: #ffffff;
  --danger: #b3392e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink); background: var(--bg);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }

button {
  font: inherit; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; padding: 9px 16px;
}
button:hover { filter: brightness(1.08); }
button.ghost {
  background: transparent; color: var(--accent);
  border: 1px solid var(--line);
}
button.ghost:hover { background: var(--accent-soft); filter: none; }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .45; cursor: default; }

input, select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff; max-width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px 40px; width: 360px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 10px 40px rgba(28,32,48,.08);
}
.login-card h1 { margin: 0; font-size: 26px; }
.login-card h1 span, .brand span { color: var(--accent); font-weight: 400; }
.login-card p { margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 20px; position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
#q { flex: 1; max-width: 640px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ---------- layout ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 230px; flex-shrink: 0; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 57px;
}
.sidebar h3 {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.sidebar section { display: flex; flex-direction: column; gap: 6px; }
.sidebar input[type="date"] { width: 100%; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.check input { width: auto; }

.content { flex: 1; padding: 18px 22px; min-width: 0; }
#results-meta { margin-bottom: 10px; font-size: 13px; }

/* ---------- result rows ---------- */
.row {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
}
.row:hover { border-color: var(--accent); }
.row .subj { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .who { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .snippet { grid-column: 1 / -1; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.badges { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.chip.out { background: #e7f5ec; color: #1e7a40; }
.chip.att { background: #f5efe0; color: #8a6d1a; }
.chip.who { background: #eef4f8; color: #2a5d7c; }
.chip.st-in_progress { background: #fff3d6; color: #8a6200; }
.chip.st-waiting_client { background: #fde8e0; color: #a04a12; }
.chip.st-done { background: #e7f5ec; color: #1e7a40; }

/* ---------- work panel ---------- */
.work-panel { margin-top: 14px; padding: 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; }
.work-row { display: flex; gap: 12px; }
.work-row label { display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted); flex: 1; }
.notes-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.note { background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.note-add { margin-top: 8px; display: flex; gap: 8px; }
.note-add input { flex: 1; }

.pager { display: flex; align-items: center; gap: 14px; margin: 16px 0; justify-content: center; }

/* ---------- detail drawer ---------- */
.detail {
  width: 480px; flex-shrink: 0; background: var(--card);
  border-left: 1px solid var(--line); padding: 20px;
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
}
.close-x { float: right; font-size: 16px; line-height: 1; }
.detail h2 { margin: 0 0 10px; font-size: 17px; }
.kv { font-size: 13px; margin: 3px 0; }
.kv b { color: var(--muted); font-weight: 500; display: inline-block; width: 62px; }
.detail .body-text {
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  white-space: pre-wrap; font-size: 13px; word-break: break-word;
  max-height: 50vh; overflow-y: auto;
}
.att-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.att-list a {
  display: flex; gap: 8px; align-items: center; text-decoration: none;
  color: var(--accent); font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
}
.att-list a:hover { background: var(--accent-soft); }
.att-size { color: var(--muted); margin-left: auto; }

/* ---------- dossier ---------- */
.dossier-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.dossier-head h2 { margin: 0; }
.fy-table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fy-table th, .fy-table td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.fy-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fy-table tr:last-child td { border-bottom: 0; }

@media (max-width: 1100px) { .detail { position: fixed; right: 0; z-index: 20; box-shadow: -8px 0 30px rgba(0,0,0,.12); } }
@media (max-width: 800px) { .sidebar { display: none; } }
