:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2027;
  --line: #262c35;
  --text: #e8eaed;
  --muted: #98a2b3;
  --accent: #ffc46b;
  --accent-2: #6ad1ff;
  --ok: #57d38c;
  --err: #ff7a7a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(1200px 600px at 20% -10%, #17212b 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(11,13,16,.86); backdrop-filter: blur(8px); z-index: 10;
}
.brand { font-weight: 700; font-size: 19px; color: var(--text); letter-spacing: .3px; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.top nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top nav a { color: var(--muted); font-size: 14px; }
.top nav a:hover { color: var(--text); text-decoration: none; }
.top .balance { color: var(--accent); font-weight: 600; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 22px 60px; }
.wrap.narrow { max-width: 460px; }

h1 { font-size: 28px; margin: 0 0 8px; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 28px 0 12px; font-weight: 600; }
h3 { font-size: 16px; margin: 18px 0 10px; font-weight: 600; }
p.lead { color: var(--muted); margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 13px; }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, #12161b 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; background: #0f1318; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3b4654; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

button, .btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 10px 16px;
  background: var(--accent); color: #16130c; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { background: #ff6b6b; color: #2a0b0b; }
button:disabled { opacity: .55; cursor: default; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { color: var(--ok); border-color: #22523a; background: #10241a; }
.badge.err { color: var(--err); border-color: #5a2626; background: #2a1212; }
.badge.work { color: var(--accent); border-color: #4a3a1e; background: #241d10; }
.badge.cost { color: var(--accent-2); border-color: #1e3b4a; background: #102029; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr:hover td { background: rgba(255,255,255,.02); }

.alert { border-radius: 10px; padding: 12px 14px; margin: 12px 0; font-size: 14px; }
.alert.err { background: #2a1212; border: 1px solid #5a2626; color: #ffb3b3; }
.alert.ok { background: #10241a; border: 1px solid #22523a; color: #a8f0c6; }
.alert.info { background: #102029; border: 1px solid #1e3b4a; color: #b8e6ff; }

.prices { display: grid; gap: 10px; }
.price-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.price-item:last-child { border-bottom: 0; }

.hero { padding: 46px 0 10px; }
.hero h1 { font-size: 38px; line-height: 1.15; max-width: 760px; }
.hero h1 em { font-style: normal; color: var(--accent); }

.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 210px); min-height: 420px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-log { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #223042; border: 1px solid #2c3d52; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.msg.system { align-self: center; color: var(--muted); font-size: 13px; background: transparent; border: 0; }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 46px; max-height: 140px; resize: none; }
.chat-form button { align-self: flex-end; }

.job-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--panel-2); }
.job-card img, .job-card video { width: 100%; border-radius: 10px; display: block; background: #000; }
.job-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

@media (max-width: 640px) {
  .hero h1 { font-size: 28px; }
  .top { padding: 12px 14px; }
  .wrap { padding: 20px 14px 40px; }
  .chat { height: calc(100vh - 260px); }
}

/* ---------- chips, upload, subnav ---------- */

.chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: #3b4654; background: #222932; }

.drop {
  position: relative; border: 1.5px dashed #34404f; border-radius: 12px; padding: 18px;
  background: #0f1318; text-align: center; transition: border-color .15s;
}
.drop.over { border-color: var(--accent); background: #1a1710; }
.drop.has-file { border-style: solid; padding: 10px; }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-hint { font-size: 13px; color: var(--muted); padding: 14px 0; }
.has-file .drop-hint { display: none; }
.upload-preview { width: 100%; border-radius: 10px; display: block; }

.subnav {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line); scrollbar-width: thin;
}
.subnav a {
  white-space: nowrap; padding: 7px 12px; border-radius: 9px; color: var(--muted); font-size: 14px;
}
.subnav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.subnav a.active { background: var(--panel-2); color: var(--accent); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 620px; }

/* ---------- tablets ---------- */
@media (max-width: 1024px) {
  .wrap { padding: 22px 18px 48px; }
  .hero h1 { font-size: 32px; }
  .grid.two { grid-template-columns: 1fr; }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .top nav { gap: 10px; font-size: 13px; }
  .top nav a { font-size: 13px; }
  .top .balance { font-size: 13px; }
  .brand { font-size: 17px; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }
  .wrap { padding: 18px 12px 40px; }
  .card { padding: 15px; border-radius: 12px; }
  .chat { height: calc(100vh - 240px); }
  .chat-form { padding: 10px; gap: 8px; }
  .chat-form button { padding: 10px 12px; }
  .msg { max-width: 92%; }
  .preview { grid-template-columns: 1fr 1fr; }
  .btn, button { padding: 11px 15px; }
  .row > .btn, .row > button { flex: 1 1 auto; }
  input, select, textarea { font-size: 16px; } /* без зума на iOS */
  .table-wrap table { min-width: 0; }

  /* таблицы превращаются в карточки */
  table.responsive { min-width: 0; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr {
    border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; margin-bottom: 10px;
    background: #111519;
  }
  table.responsive tr:hover td { background: transparent; }
  table.responsive td {
    display: flex; gap: 10px; justify-content: space-between; align-items: flex-start;
    border: 0; padding: 6px 0; font-size: 14px;
  }
  table.responsive td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px; flex: 0 0 42%; padding-top: 2px;
  }
  table.responsive td:empty { display: none; }
  table.responsive td[data-label=""]::before { content: none; }
  table.responsive td > * { max-width: 58%; }
  table.responsive td.full { display: block; }
  table.responsive td.full > * { max-width: 100%; }
  table.responsive td.full::before { display: block; margin-bottom: 6px; }
  table.responsive td form { width: 100%; }
  .hide-sm { display: none !important; }
  .subnav a { font-size: 13px; padding: 6px 10px; }
  .prices .price-item { font-size: 13px; }
}
