:root {
  --bg: #0f0f11;
  --bg2: #18181c;
  --bg3: #222228;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #f0eff4;
  --text2: #9694a0;
  --text3: #5a5866;
  --accent: #7c6af7;
  --accent2: #5e4fd4;
  --accent-bg: rgba(124,106,247,0.12);
  --accent-border: rgba(124,106,247,0.3);
  --green: #3ecf8e;
  --green-bg: rgba(62,207,142,0.1);
  --red: #f87171;
  --red-bg: rgba(248,113,113,0.1);
  --amber: #fbbf24;
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ── */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ── TOP BAR ── */
.topbar {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-logo span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 7px;
  font-size: 13px;
}
.topbar-count {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
}

/* ── CONTENT ── */
.content { flex: 1; padding: 0 0 100px; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(15,15,17,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding: 0 0 env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  padding: 12px 4px 10px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color .2s;
  position: relative;
}
.nav-btn.active { color: var(--accent); }
.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
}
.nav-icon { font-size: 20px; line-height: 1; }

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── SEARCH / FILTER ── */
.search-area {
  padding: 14px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 57px;
  z-index: 40;
}
.search-wrap { flex: 1; position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text3); pointer-events: none; }
.search-wrap input { padding-left: 34px; }

input, select, textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239694a0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.prov-select { width: 140px; flex-shrink: 0; font-size: 13px; }

/* ── LIST ── */
.list-meta {
  padding: 10px 16px 4px;
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
}
.list-inner { padding: 8px 16px; }

.repair-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  overflow: hidden;
}
.repair-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}
.repair-card:hover { border-color: var(--border2); background: var(--bg3); }
.repair-card:hover::before { opacity: 1; }
.repair-card:active { transform: scale(0.99); }

.rc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.rc-name { font-weight: 600; font-size: 15px; letter-spacing: -0.2px; }
.rc-price { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--green); background: var(--green-bg); padding: 2px 8px; border-radius: 20px; white-space: nowrap; margin-left: 8px; }
.rc-price.empty-price { color: var(--text3); background: none; }
.rc-model { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.rc-bottom { display: flex; justify-content: space-between; align-items: center; }
.rc-loc { font-size: 12px; color: var(--text3); }
.rc-date { font-size: 12px; color: var(--text3); font-family: var(--mono); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ── FORM ── */
.form-wrap { padding: 16px; }
.form-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.form-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  font-family: var(--mono);
}
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 5px;
  font-weight: 500;
}
label .req { color: var(--accent); margin-left: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  transition: all .15s;
  display: block;
  margin-bottom: 10px;
  letter-spacing: -0.1px;
}
.btn:hover { border-color: var(--border2); background: var(--bg2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-danger { color: var(--red); border-color: rgba(248,113,113,0.25); background: var(--red-bg); }
.btn-danger:hover { border-color: var(--red); }

/* ── DETAIL ── */
.detail-wrap { padding: 16px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  padding: 0;
  margin-bottom: 16px;
  transition: color .15s;
}
.back-btn:hover { color: var(--text); }

.detail-header {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.detail-client-name { font-size: 20px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 4px; }
.detail-client-sub { font-size: 13px; color: var(--text2); }
.edit-btn-sm {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.edit-btn-sm:hover { color: var(--text); border-color: var(--accent); }

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text3);
  font-family: var(--mono);
  margin: 14px 0 6px;
}
.info-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 13px; color: var(--text2); flex-shrink: 0; }
.info-val { font-size: 13px; text-align: right; word-break: break-word; }

.text-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
  white-space: pre-wrap;
}
.price-block {
  background: var(--green-bg);
  border: 1px solid rgba(62,207,142,0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.price-label { font-size: 12px; color: var(--green); font-family: var(--mono); letter-spacing: 0.5px; margin-bottom: 6px; }
.price-amount { font-size: 32px; font-weight: 600; color: var(--green); font-family: var(--mono); letter-spacing: -1px; }

/* ── STATS ── */
.stats-wrap { padding: 16px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.stat-label { font-size: 11px; color: var(--text3); font-family: var(--mono); letter-spacing: 0.4px; margin-bottom: 6px; }
.stat-val { font-size: 26px; font-weight: 600; font-family: var(--mono); letter-spacing: -1px; }
.stat-val.green { color: var(--green); font-size: 20px; }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); }
.bar-row:last-child { border-bottom: none; }
.bar-name { font-size: 13px; color: var(--text2); min-width: 100px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.bar-track { flex: 1; height: 4px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.bar-count { font-size: 12px; color: var(--text3); font-family: var(--mono); min-width: 20px; text-align: right; }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
