@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #0c0e12;
  --panel: #151a21;
  --panel2: #1b212a;
  --line: #262f3a;
  --text: #e6ebf1;
  --dim: #8290a0;
  --accent: #f0a500;
  --free: #eef3f8;      /* свободен — белый */
  --busy: #f0a500;      /* занят — жёлтый */
  --cancelled: #ef4444; /* отменён — красный */
  --done: #3ddc97;      /* выполнен — зелёный */
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }

.brand { display: flex; align-items: baseline; gap: 9px; }
.brand .mark {
  width: 12px; height: 12px; border-radius: 3px; align-self: center;
  background: linear-gradient(135deg, var(--accent), #ff7a00);
}
.brand b { font-family: 'Bebas Neue', Impact, sans-serif; font-size: 24px; letter-spacing: 2px; }
.brand small {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 2px;
  color: var(--dim); text-transform: uppercase;
}
.brand.small b { font-size: 19px; }

/* ─── вход ─── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate[hidden] { display: none; }
.gate-box { width: 100%; max-width: 380px; }
.gate-box .brand { margin-bottom: 26px; }
.gate .hint { color: var(--dim); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }
.fine { color: var(--dim); font-size: 11.5px; line-height: 1.5; }

/* ─── каркас ─── */
.app { min-height: 100vh; padding-bottom: 92px; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: rgba(12,14,18,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top .brand { flex: 0 0 auto; }
.tabs { flex: 1; display: flex; gap: 4px; justify-content: center; }
.tabs button {
  position: relative; cursor: pointer; border: 1px solid transparent; background: none;
  color: var(--dim); border-radius: 9px; padding: 7px 13px; font-size: 13.5px; font-weight: 500;
}
.tabs button.on { color: var(--text); background: var(--panel); border-color: var(--line); }
.tabs .dot {
  position: absolute; top: 4px; right: 5px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
}
.who {
  flex: 0 0 auto; cursor: pointer; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 11px; color: var(--text); text-align: right; line-height: 1.25;
}
.who span { display: block; font-size: 13px; font-weight: 600; }
.who i {
  font-style: normal; font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px; letter-spacing: 1.4px; color: var(--dim); text-transform: uppercase;
}

.pane { padding: 14px 16px 0; max-width: 900px; margin: 0 auto; }
.pane[hidden] { display: none; }

/* ─── фильтры ─── */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: 0 0 auto; cursor: pointer; background: transparent; border: 1px solid var(--line);
  color: var(--dim); border-radius: 20px; padding: 7px 13px; font-size: 12.5px;
}
.filters button.on { color: #0c0e12; background: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ─── карточки ─── */
.list { display: flex; flex-direction: column; gap: 11px; }
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px; overflow: hidden;
}
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line); }
.card::before { width: 4px; }
.card.free::before { background: var(--free); }
.card.busy::before { background: var(--busy); }
.card.cancelled::before { background: var(--cancelled); }
.card.done::before { background: var(--done); }
.card.free { background: linear-gradient(90deg, rgba(238,243,248,.07), transparent 42%), var(--panel); }
.card.busy { background: linear-gradient(90deg, rgba(240,165,0,.09), transparent 42%), var(--panel); }
.card.cancelled { background: linear-gradient(90deg, rgba(239,68,68,.09), transparent 42%), var(--panel); opacity: .8; }
.card.done { background: linear-gradient(90deg, rgba(61,220,151,.08), transparent 42%), var(--panel); opacity: .82; }

.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.num { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--dim); letter-spacing: .5px; }
.num b { color: var(--text); }
.state {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 1.2px;
  text-transform: uppercase; padding: 4px 9px; border-radius: 20px; border: 1px solid var(--line);
}
.state.free { color: #f4f8fc; border-color: rgba(238,243,248,.35); }
.state.busy { color: var(--busy); border-color: rgba(240,165,0,.4); }
.state.cancelled { color: var(--cancelled); border-color: rgba(239,68,68,.4); }
.state.done { color: var(--done); border-color: rgba(61,220,151,.4); }

.flag {
  margin-top: 10px; padding: 9px 11px; border-radius: 10px;
  background: rgba(240,165,0,.1); border: 1px solid rgba(240,165,0,.35);
  color: #ffd166; font-size: 13px;
}

.legend {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: .8px;
  color: var(--dim); text-transform: uppercase; white-space: nowrap;
}
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.legend i.free { background: var(--free); }
.legend i.busy { background: var(--busy); }
.legend i.cancelled { background: var(--cancelled); }
.legend i.done { background: var(--done); }

.chat-day {
  align-self: center; margin: 6px 0 2px; padding: 3px 11px; border-radius: 20px;
  background: var(--panel2); border: 1px solid var(--line);
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  letter-spacing: 1.2px; color: var(--dim); text-transform: uppercase;
}

.when { margin-top: 9px; font-size: 15px; font-weight: 600; }
.when span { color: var(--dim); font-weight: 400; }

.route { margin: 10px 0; padding-left: 15px; position: relative; }
.route::before {
  content: ''; position: absolute; left: 3px; top: 9px; bottom: 9px; width: 1px;
  background: repeating-linear-gradient(180deg, #46525f 0 3px, transparent 3px 7px);
}
.route div { position: relative; padding: 2px 0; font-size: 15px; }
.route div::before {
  content: ''; position: absolute; left: -15px; top: 9px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--bg); border: 1.5px solid #5b6875;
}
.route div.b::before { background: var(--accent); border-color: var(--accent); }
.card.free .route div.b::before { background: var(--free); border-color: var(--free); }

.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 8px; font-size: 12px; color: var(--text);
}
.chip.muted { color: var(--dim); }
.chip.money { font-weight: 600; }
.chip a { color: var(--confirmed); text-decoration: none; }
.note { margin-top: 9px; font-size: 13px; color: var(--dim); line-height: 1.45; }
.who-line {
  margin-top: 10px; font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 1.1px; color: var(--dim); text-transform: uppercase;
}

.acts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.btn {
  flex: 1 1 auto; cursor: pointer; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 500;
}
.btn:active { transform: scale(.985); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #12151a; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.danger { background: transparent; border-color: rgba(239,68,68,.4); color: #d97070; }
.btn[disabled] { opacity: .55; cursor: default; }
.wide-btn { width: 100%; margin-top: 10px; }

.log { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 9px; }
.log summary { cursor: pointer; font-size: 12px; color: var(--dim); }
.log ul { margin: 8px 0 0; padding-left: 16px; }
.log li { font-size: 12px; color: var(--dim); line-height: 1.55; }

.empty { text-align: center; padding: 50px 20px; color: var(--dim); }
.empty b { display: block; font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty p { margin: 0; font-size: 13.5px; line-height: 1.5; }

/* ─── чат ─── */
.chat {
  display: flex; flex-direction: column; gap: 8px;
  height: calc(100vh - 220px); overflow-y: auto; padding-bottom: 8px;
}
.msg {
  align-self: flex-start; max-width: 82%; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 9px 12px;
}
.msg.own { align-self: flex-end; background: #1d2836; border-color: #2b3d52; border-radius: 14px 14px 4px 14px; }
.msg b { display: block; font-size: 12px; color: var(--accent); margin-bottom: 3px; }
.msg p { margin: 0; font-size: 14.5px; line-height: 1.4; word-break: break-word; }
.msg i {
  display: block; font-style: normal; margin-top: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--dim);
}
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px;
  padding: 10px 16px 16px; background: var(--bg); border-top: 1px solid var(--line);
}
.composer input { flex: 1; border-radius: 22px; }
.composer button {
  width: 46px; flex: 0 0 auto; border: none; border-radius: 50%;
  background: var(--accent); color: #12151a; font-size: 15px; cursor: pointer;
}

/* ─── формы ─── */
.grid { display: grid; gap: 11px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid label, .card.form label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--dim); }
.grid label.wide { grid-column: 1 / -1; }
input, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; color: var(--text); font-size: 15px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { min-height: 66px; resize: vertical; }
.row { display: flex; gap: 8px; margin-top: 16px; }
.card.form { margin-top: 14px; }
.card.form h3 {
  margin: 0 0 12px; font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: 1.6px; color: var(--dim); text-transform: uppercase; font-weight: 400;
}
.card.form .btn { margin-top: 12px; }

.team-row { display: flex; align-items: center; gap: 8px; }
.team-row .name { flex: 1; min-width: 0; }
.team-row .name b { display: block; font-size: 15px; }
.team-row .name small {
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  letter-spacing: 1.1px; color: var(--dim); text-transform: uppercase;
}
.mini {
  flex: 0 0 auto; cursor: pointer; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 12px;
}
.mini.danger { color: #d97070; border-color: rgba(239,68,68,.35); }

/* ─── шторки ─── */
.fab {
  position: fixed; right: 16px; bottom: 20px; z-index: 30; cursor: pointer; border: none;
  background: var(--accent); color: #12151a; border-radius: 14px; padding: 14px 20px;
  font-size: 14px; font-weight: 700; box-shadow: 0 12px 30px rgba(0,0,0,.55);
}
.fab[hidden] { display: none; }
.veil { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 40; }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 41;
  width: min(560px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-bottom: none;
  border-radius: 18px 18px 0 0; padding: 18px 16px 26px;
}
.sheet[hidden] { display: none; }
.sheet h2 { margin: 2px 0 14px; font-family: 'Bebas Neue', sans-serif; font-size: 24px; letter-spacing: 1.2px; }
.sheet .fine { margin: 12px 0 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 60;
  background: #232c37; border: 1px solid var(--line); border-radius: 10px; padding: 11px 16px;
  font-size: 13.5px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 86%;
}
.toast.on { opacity: 1; }

@media (max-width: 560px) {
  .top { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; justify-content: stretch; }
  .tabs button { flex: 1; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
