:root {
  --bg: #eef2f4;
  --side: #2fc6f6;
  --card: #fff;
  --text: #333;
  --muted: #6a737c;
  --line: #dce3e8;
  --accent: #2fc6f6;
  --danger: #c0392b;
  --radius: 4px;
  --sidebar-width: 200px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: #005a8c; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 50;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transform: translateY(-160%);
}
.skip-link:focus-visible { transform: none; }
.nav-toggle,
.nav-scrim {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.nav-burger { display: none; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width); background: #fff; border-right: 1px solid var(--line); border-left: 4px solid var(--side); padding: 16px 0; }
.brand { font-weight: 700; padding: 0 20px 16px; font-size: 18px; }
.nav-item { display: block; padding: 10px 20px; color: var(--text); text-decoration: none; }
.nav-item.is-on { background: #e9f8fd; color: #008da6; font-weight: 600; }
.nav-logout { margin: 24px 20px; }
.main {
  margin-left: var(--sidebar-width);
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  min-height: 100%;
}
.main:focus { outline: none; }
.main-login { display: flex; align-items: center; justify-content: center; min-height: 100%; }
.login-card { background: var(--card); padding: 32px; width: min(360px, 100%); box-shadow: 0 2px 8px rgba(0,0,0,.06); border-radius: var(--radius); }
.login-card label, .card-block label { display: block; margin: 12px 0; }
.login-card input, .filters input, .filters select, .inline input, .card-block input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar { background: #fff; padding: 10px 12px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: -16px -20px 16px; border-bottom: 1px solid var(--line); }
.view-switch a { display: inline-block; padding: 6px 12px; text-decoration: none; color: var(--text); }
.view-switch a.is-on { background: #e9f8fd; font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.filters input, .filters select { width: auto; }
.kanban { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 20px; }
.kanban-col { flex: 0 0 280px; background: #f7f9fa; min-height: 200px; max-height: calc(100vh - 9rem); max-height: calc(100dvh - 9rem); overflow-y: auto; }
.kanban-head { background: #fff; padding: 10px 12px; border-top: 4px solid #ccc; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.kanban-head h2 { font-size: inherit; margin: 0; }
.kanban-sum { color: var(--muted); font-weight: 400; font-size: 12px; }
.kanban-body { padding: 8px; }
.deal-card { display: block; width: 100%; text-align: left; background: #fff; border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 10px; margin-bottom: 8px; color: inherit; text-decoration: none; border-radius: var(--radius); }
.deal-title { font-weight: 600; margin-bottom: 4px; }
.deal-price { font-weight: 700; }
.deal-client { color: var(--muted); font-size: 13px; margin-top: 2px; }
.deal-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.badge { background: #eef2f4; padding: 1px 6px; font-size: 11px; }
.badge-kwork { background: #e8f4fc; }
.badge-fl { background: #fdeee8; }
.badge-upwork { background: #e8f8ee; }
.badge-onclancer { background: #f3e8fc; }
.badge-avito { background: #fff3d6; }
.muted { color: var(--muted); }
.empty { padding: 12px; }
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; background: #fff; }
.grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.row-link { cursor: pointer; }
.row-link:hover { background: #f4fbfd; }
.flash, .error { padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius); }
.flash-ok { background: #e5f7e5; }
.flash-error, .error { background: #fdecea; color: #8b1a12; }
.htmx-indicator { display: none; }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { display: block; }
#htmx-busy { position: fixed; top: 12px; right: 12px; z-index: 40; background: var(--card); padding: 8px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.12); border-radius: var(--radius); }
dialog.slider {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  max-width: none;
  max-height: none;
  height: 100%;
  width: min(560px, 100%);
  border: 0;
  padding: 12px 20px 40px;
  background: var(--card);
  box-shadow: -4px 0 16px rgba(0,0,0,.12);
  overflow: auto;
}
dialog.slider::backdrop { background: rgba(0,0,0,.25); }
.slider-bar { display: flex; justify-content: flex-end; margin: 0 0 8px; }
.detail-close { float: none; font-size: 22px; min-width: 24px; min-height: 24px; }
.prose { white-space: pre-wrap; background: #f7f9fa; padding: 12px; }
.timeline { padding-left: 18px; }
.card-block { background: #fff; padding: 16px; margin: 16px 0; border-radius: var(--radius); }
details.card-block > summary { cursor: pointer; }
details.card-block > summary h2 { display: inline; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eef2f4; border: 0; padding: 4px 4px 4px 8px; border-radius: var(--radius); }
.chip button { border: 0; background: none; min-height: 24px; min-width: 24px; padding: 0; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin: 16px 0; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--text); background: #fff; white-space: nowrap; }
.tabs a.is-on { background: #e9f8fd; font-weight: 600; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.checks label { display: block; margin: 6px 0; }
.radio { margin-right: 16px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { width: auto; }
.stage-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0; }
.stage-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.stage-form select, .stage-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.stage-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.btn, button {
  background: var(--accent);
  border: 0;
  color: #123;
  padding: 8px 14px;
  font-weight: 600;
  border-radius: var(--radius);
  min-height: 24px;
  min-width: 24px;
  cursor: pointer;
}
.btn-ghost, .nav-logout button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-danger { background: var(--danger); color: #fff; }
pre { white-space: pre-wrap; background: #f7f9fa; padding: 8px; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; }
.chat { display: flex; gap: 12px; align-items: stretch; height: calc(100dvh - 88px); min-height: 320px; }
.chat-list { flex: 0 0 280px; background: #f7f9fa; overflow-y: auto; }
.chat-item { display: block; padding: 10px 12px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.chat-item.is-on { background: #e9f8fd; }
.chat-thread { flex: 1; background: #fff; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
.bubble { max-width: 80%; margin: 8px 0; padding: 8px 10px; background: #f4f6f8; }
.bubble.mine { margin-left: auto; background: #e5f7e5; }
.chat-send { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-send label { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12px; color: var(--muted); }
.chat-send textarea { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); width: 100%; }
@media (max-width: 800px) {
  .nav-burger {
    display: inline-flex;
    align-items: center;
    position: fixed;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    z-index: 30;
    min-height: 44px;
    padding: 0 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
  }
  .nav-scrim {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--sidebar-width);
    width: auto;
    height: auto;
    overflow: visible;
    clip: unset;
    clip-path: none;
    z-index: 20;
    background: rgba(0,0,0,.35);
    color: transparent;
    cursor: pointer;
  }
  .nav-toggle:checked ~ .nav-scrim { display: block; }
  .sidebar {
    z-index: 25;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .nav-toggle:checked ~ .sidebar { transform: translateX(0); }
  .main {
    margin-left: 0;
    padding-top: calc(56px + env(safe-area-inset-top, 0px));
  }
  .btn, button { min-height: 44px; }
  .chip button { min-height: 44px; min-width: 44px; }
  .checks { grid-template-columns: 1fr; }
  .filters label, .filters input, .filters select { width: 100%; }
  .kanban-col {
    max-height: calc(100vh - 12rem);
    max-height: calc(100dvh - 12rem);
  }
  .chat { height: calc(100dvh - 120px); flex-direction: column; }
  .chat-list { flex: 0 0 160px; }
  .chat.is-open .chat-list { display: none; }
  .chat-send { flex-direction: column; align-items: stretch; }
}
