:root {
  --bg: #0A0A0A;
  --s1: #141414;
  --s2: #1C1C1C;
  --s3: #242424;
  --border: #2C2C2C;
  --accent: #E8FF47;
  --accent2: #FF6B35;
  --text: #F0F0F0;
  --muted: #5A5A5A;
  --muted2: #888;
  --r: 12px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Topbar ── */
.tb {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(10,10,10,.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top, 10px) 14px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.logo { font-family: 'Space Mono', monospace; font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 2px; white-space: nowrap; }
.logo span { color: var(--muted2); }
.tb-right { display: flex; gap: 7px; align-items: center; }
.role-sel {
  background: var(--s2); border: 1px solid var(--border); color: var(--text);
  font-family: 'Manrope', sans-serif; font-size: 11px; font-weight: 700;
  padding: 5px 9px; border-radius: 20px; outline: none; -webkit-appearance: none; cursor: pointer;
}
.btn-plus {
  width: 33px; height: 33px; border-radius: 50%; background: var(--accent);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #000; flex-shrink: 0;
}
.btn-plus:active { transform: scale(.92); }

/* ── Main ── */
.main {
  padding-top: calc(env(safe-area-inset-top, 0px) + 56px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
}

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px 12px 6px; }
.stat { background: var(--s1); border: 1px solid var(--border); border-radius: 10px; padding: 10px 8px; text-align: center; }
.stat-n { font-family: 'Space Mono', monospace; font-size: 20px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-l { font-size: 8px; color: var(--muted2); margin-top: 3px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; padding: 6px 12px; border-radius: 20px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border); background: var(--s1); color: var(--muted2); cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* ── Order cards ── */
.orders { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--s1); border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; cursor: pointer; transition: transform .1s;
}
.card:active { transform: scale(.985); }
.card-bar { height: 3px; }
.card-body { padding: 12px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 7px; }
.card-id { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--muted2); }
.badge-msg { background: var(--accent2); color: #fff; border-radius: 10px; padding: 1px 5px; font-size: 9px; }
.pill { font-size: 9px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; }
.card-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.card-client { font-size: 11px; color: var(--muted2); margin-bottom: 7px; }
.card-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.meta { font-size: 10px; color: var(--muted2); display: flex; align-items: center; gap: 3px; }
.meta strong { color: var(--text); font-weight: 600; }
.prog-wrap { margin-top: 7px; }
.prog-lbl { display: flex; justify-content: space-between; font-size: 9px; color: var(--muted2); margin-bottom: 3px; }
.prog-track { height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 2px; }

/* ── Bottom nav ── */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(10,10,10,.97);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 0 calc(env(safe-area-inset-bottom, 6px));
}
.ni { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0; cursor: pointer; font-size: 8px; letter-spacing: .5px; color: var(--muted2); text-transform: uppercase; font-weight: 700; }
.ni.active { color: var(--accent); }
.ni-icon { font-size: 19px; line-height: 1; }

/* ── Detail overlay ── */
.overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.75); backdrop-filter: blur(8px); display: none; align-items: flex-end; }
.overlay.open { display: flex; }
.sheet { width: 100%; max-height: 94vh; background: var(--s1); border-radius: 20px 20px 0 0; border-top: 1px solid var(--border); overflow-y: auto; animation: up .28s cubic-bezier(.32,.72,0,1); }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 10px auto 0; }

/* ── Modal tabs ── */
.m-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 16px; }
.m-tab { flex: 1; text-align: center; padding: 11px 2px; font-size: 11px; font-weight: 700; color: var(--muted2); cursor: pointer; border-bottom: 2px solid transparent; }
.m-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Sections ── */
.sec { padding: 14px 16px 0; }
.sec-title { font-size: 9px; letter-spacing: 1.5px; font-weight: 700; color: var(--muted2); text-transform: uppercase; margin-bottom: 10px; }

/* ── Pipeline ── */
.pipe { display: flex; align-items: flex-start; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.pipe::-webkit-scrollbar { display: none; }
.pipe-step { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; }
.pipe-dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.pipe-dot.done { background: var(--accent); border-color: var(--accent); color: #000; }
.pipe-dot.cur { border-color: var(--accent2); color: var(--accent2); animation: glow 1.5s infinite; }
@keyframes glow { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,53,.4); } 50% { box-shadow: 0 0 0 6px rgba(255,107,53,0); } }
.pipe-lbl { font-size: 8px; color: var(--muted2); text-align: center; max-width: 44px; line-height: 1.3; }
.pipe-line { width: 16px; height: 2px; background: var(--border); margin-top: 14px; flex-shrink: 0; }
.pipe-line.done { background: var(--accent); }

/* ── Detail grid ── */
.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.di { background: var(--s2); border-radius: 8px; padding: 9px 11px; }
.di.full { grid-column: 1 / -1; }
.di-l { font-size: 9px; color: var(--muted2); margin-bottom: 2px; }
.di-v { font-size: 12px; font-weight: 600; line-height: 1.4; }

/* ── Photo grid ── */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-box {
  aspect-ratio: 1; border-radius: 8px; background: var(--s2);
  border: 1.5px dashed var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
  position: relative; overflow: hidden;
}
.photo-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.photo-box-lbl { font-size: 9px; color: var(--muted2); text-align: center; line-height: 1.4; }
.photo-box input[type=file] { display: none; }

/* ── TZ form ── */
.tz-grid { display: flex; flex-direction: column; gap: 10px; }
.tz-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tz-lbl { font-size: 9px; color: var(--muted2); letter-spacing: .5px; font-weight: 700; margin-bottom: 4px; text-transform: uppercase; }
.tz-lbl span { color: var(--muted); font-size: 8px; font-weight: 400; }
.tz-inp {
  width: 100%; background: var(--s2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; color: var(--text); font-family: 'Manrope', sans-serif; font-size: 13px;
  outline: none; -webkit-appearance: none;
}
.tz-inp:focus { border-color: var(--accent); }
.tz-inp[readonly] { opacity: .7; cursor: default; }
select.tz-inp { cursor: pointer; }
option { background: var(--s1); }
textarea.tz-inp { resize: none; line-height: 1.5; }

/* ── Chat ── */
.msgs-wrap { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 180px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.me { flex-direction: row-reverse; }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--s3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.av.cn { background: #1a2a1a; border-color: #2a4a2a; color: #4ade80; }
.av.me-av { background: #1a1a2a; border-color: #2a2a4a; color: var(--accent); }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.msg:not(.me) .bubble { background: var(--s2); border-radius: 0 12px 12px 12px; }
.msg.me .bubble { background: var(--accent); color: #000; border-radius: 12px 0 12px 12px; }
.bubble-meta { font-size: 9px; margin-top: 3px; opacity: .6; }
.chat-bottom {
  position: sticky; bottom: 0; background: var(--s1);
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 10px);
  border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end;
}
.chat-inp {
  flex: 1; background: var(--s2); border: 1px solid var(--border); border-radius: 20px;
  padding: 10px 14px; color: var(--text); font-family: 'Manrope', sans-serif; font-size: 13px;
  outline: none; resize: none; max-height: 80px;
}
.chat-inp:focus { border-color: var(--accent); }
.btn-send { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; color: #000; flex-shrink: 0; }

/* ── Action buttons ── */
.act-btn {
  padding: 11px 14px; border-radius: 10px; font-size: 11px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--border); font-family: 'Manrope', sans-serif; width: 100%; margin-bottom: 8px; text-align: center;
}
.act-btn.pri { background: var(--accent); color: #000; border-color: var(--accent); }
.act-btn.sec { background: var(--s2); color: var(--text); }
.act-btn:active { transform: scale(.97); }
.act-btn.danger { background: #2a1a1a; color: #ff6b6b; border-color: #4a1a1a; }

/* ── New order form ── */
.form-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.8); backdrop-filter: blur(10px); display: none; align-items: flex-end; }
.form-overlay.open { display: flex; }
.form-sheet { width: 100%; max-height: 95vh; background: var(--s1); border-radius: 20px 20px 0 0; border-top: 1px solid var(--border); overflow-y: auto; animation: up .28s cubic-bezier(.32,.72,0,1); }
.form-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 0; }
.form-title { font-size: 17px; font-weight: 800; }
.btn-x { width: 30px; height: 30px; border-radius: 50%; background: var(--s2); border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.form-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.fl { font-size: 10px; color: var(--muted2); letter-spacing: .5px; font-weight: 700; margin-bottom: 5px; text-transform: uppercase; }
.fi { width: 100%; background: var(--s2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; color: var(--text); font-family: 'Manrope', sans-serif; font-size: 13px; outline: none; -webkit-appearance: none; }
.fi:focus { border-color: var(--accent); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-sub { width: 100%; padding: 13px; border-radius: 11px; background: var(--accent); border: none; cursor: pointer; font-family: 'Manrope', sans-serif; font-size: 14px; font-weight: 800; color: #000; margin-top: 4px; }
.btn-sub:active { transform: scale(.98); }

/* ── Search ── */
.search-wrap { padding: 6px 12px; }
.search-inp {
  width: 100%; background: var(--s2); border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 14px; color: var(--text); font-family: 'Manrope', sans-serif; font-size: 13px;
  outline: none;
}
.search-inp:focus { border-color: var(--accent); }
.search-inp::placeholder { color: var(--muted2); }

/* ── Empty state ── */
.empty { text-align: center; padding: 50px 20px; color: var(--muted2); }
.empty-ico { font-size: 44px; margin-bottom: 10px; }
.empty-t { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 5px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--accent); color: #000;
  padding: 9px 18px; border-radius: 20px; font-size: 12px; font-weight: 700;
  opacity: 0; transition: all .25s; z-index: 999; white-space: nowrap; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #ff6b6b; color: #fff; }

/* ── Misc ── */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.pb { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
.sub-title { font-size: 9px; color: var(--muted2); letter-spacing: 1px; font-weight: 700; text-transform: uppercase; }
