:root {
  --bg: #050609;
  --panel: #0d1018;
  --panel-2: #131827;
  --card: #161c2d;
  --border: rgba(255,255,255,.09);
  --text: #f6f7fb;
  --muted: #9aa4bd;
  --accent: #d4af37;
  --accent-2: #00d4ff;
  --danger: #ff5572;
  --success: #21d07a;
  --warning: #f7c948;
  --shadow: 0 30px 80px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Tahoma, Arial, sans-serif; }
body:before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 32%),
    radial-gradient(circle at 80% 0%, rgba(0,212,255,.18), transparent 36%),
    linear-gradient(135deg, rgba(255,255,255,.03), transparent 40%);
  pointer-events: none;
}
a { color: inherit; }
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
.login-wrap, .quote-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
}
.login-card, .quote-card {
  width: min(1050px, 100%);
  background: linear-gradient(145deg, rgba(19,24,39,.96), rgba(8,10,15,.96));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 28px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-hero { padding: 46px; border-left: 1px solid var(--border); position: relative; overflow: hidden; }
.login-hero:before {
  content: "CRM";
  position: absolute;
  left: -30px;
  bottom: 10px;
  font-size: 140px;
  font-weight: 900;
  color: rgba(255,255,255,.035);
  letter-spacing: 8px;
}
.brand-badge {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 800;
}
.login-hero h1 { font-size: 42px; line-height: 1.25; margin: 28px 0 14px; }
.login-hero p { color: var(--muted); line-height: 1.9; margin: 0; font-size: 16px; }
.login-form { padding: 46px; }
.login-form h2, .quote-card h2 { margin: 0 0 8px; font-size: 28px; }
.subtitle { color: var(--muted); margin: 0 0 24px; line-height: 1.7; }
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--muted); margin-bottom: 7px; font-size: 13px; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.045);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  transition: .2s;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.select option { background: #111827; color: #fff; }
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  color: #070707;
  background: linear-gradient(135deg, var(--accent), #fff2a8);
  font-weight: 900;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 18%, transparent);
}
.btn.secondary { color: var(--text); background: rgba(255,255,255,.07); box-shadow: none; border: 1px solid var(--border); }
.btn.danger { color: white; background: linear-gradient(135deg, #ff5572, #b51d3b); }
.btn.success { color: #04140d; background: linear-gradient(135deg, #21d07a, #9fffd0); }
.btn.block { width: 100%; }
.demo-users { display: grid; gap: 8px; margin-top: 18px; }
.demo-line { color: var(--muted); font-size: 12px; background: rgba(255,255,255,.045); border: 1px solid var(--border); padding: 9px 11px; border-radius: 12px; direction: ltr; text-align: left; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; position: relative; }
.sidebar { background: rgba(7,9,14,.86); border-left: 1px solid var(--border); padding: 18px; position: sticky; top: 0; height: 100vh; overflow: auto; backdrop-filter: blur(18px); }
.logo { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 16%, transparent), rgba(255,255,255,.04)); border: 1px solid var(--border); }
.logo-mark { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #050609; background: var(--accent); font-weight: 900; }
.logo-title { font-weight: 900; }
.logo-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.company-box { margin: 16px 0; }
.company-box .select { padding: 11px; font-size: 13px; }
.nav { display: grid; gap: 7px; margin-top: 16px; }
.nav button {
  width: 100%;
  text-align: right;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 13px;
  border-radius: 14px;
  font-weight: 800;
}
.nav button.active, .nav button:hover { color: var(--text); background: rgba(255,255,255,.07); border-color: var(--border); }
.main { padding: 24px; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title h1 { margin: 0; font-size: 28px; }
.page-title p { margin: 6px 0 0; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.06); border: 1px solid var(--border); border-radius: 999px; padding: 8px 10px 8px 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #000; display: grid; place-items: center; font-weight: 900; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(5, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.card { background: linear-gradient(145deg, rgba(22,28,45,.96), rgba(13,16,24,.96)); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 18px 48px rgba(0,0,0,.22); padding: 18px; }
.stat { position: relative; overflow: hidden; }
.stat:before { content: ""; position: absolute; inset-inline-start: -40px; top: -40px; width: 110px; height: 110px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, transparent); filter: blur(2px); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 900; margin-top: 8px; }
.card h3 { margin: 0 0 14px; }
.table-wrap { overflow: auto; border-radius: 16px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
th { color: var(--muted); font-size: 12px; background: rgba(255,255,255,.04); position: sticky; top: 0; }
td { color: #eef2ff; font-size: 13px; }
tr:hover td { background: rgba(255,255,255,.025); }
.badge { display: inline-flex; padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--border); font-size: 12px; color: var(--text); white-space: nowrap; }
.badge.green { color: var(--success); border-color: rgba(33,208,122,.35); background: rgba(33,208,122,.08); }
.badge.red { color: var(--danger); border-color: rgba(255,85,114,.35); background: rgba(255,85,114,.08); }
.badge.yellow { color: var(--warning); border-color: rgba(247,201,72,.35); background: rgba(247,201,72,.08); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.alert { padding: 12px 14px; border-radius: 14px; margin: 12px 0; border: 1px solid var(--border); background: rgba(255,255,255,.06); color: var(--muted); }
.alert.success { color: var(--success); border-color: rgba(33,208,122,.3); }
.alert.error { color: var(--danger); border-color: rgba(255,85,114,.3); }
.quote-card { display: block; max-width: 920px; padding: 0; }
.quote-header { padding: 28px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), rgba(255,255,255,.03)); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.quote-body { padding: 28px; }
.quote-logo { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; color: #000; background: var(--accent); font-weight: 900; }
.quote-total { font-size: 34px; font-weight: 900; color: var(--accent); }
.quote-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.mobile-list { display: grid; gap: 14px; }
.job-mobile-card { border: 1px solid var(--border); border-radius: 22px; padding: 16px; background: rgba(255,255,255,.045); }
.photo-preview { max-width: 130px; max-height: 90px; border-radius: 12px; border: 1px solid var(--border); display: block; margin-top: 8px; object-fit: cover; }
.footer-note { color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.7; }
@media (max-width: 1100px) {
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .login-card { grid-template-columns: 1fr; }
  .login-hero { border-left: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: 1fr; }
  .quote-actions { grid-template-columns: 1fr; }
}
@media print {
  body:before, .quote-actions, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .quote-wrap { padding: 0; min-height: auto; display: block; }
  .quote-card { box-shadow: none; border: none; background: #fff; color: #000; width: 100%; }
  .quote-body, .quote-header { background: #fff; color: #000; }
  table, th, td { color: #000; border-color: #ddd; }
}
.logo-image-box { overflow: hidden; background: rgba(255,255,255,.08); border: 1px solid var(--border); }
.logo-image-box img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 4px; }
.preview-logo { justify-content: flex-start; margin-bottom: 14px; }
.preview-logo .logo-mark { width: 70px; height: 70px; border-radius: 20px; }
.quote-logo.logo-image-box img { padding: 6px; }
.checks { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.check-line { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: rgba(255,255,255,.045); color: var(--text); font-weight: 800; }
.check-line input { accent-color: var(--accent); }
.btn.mini { padding: 7px 10px; border-radius: 10px; font-size: 12px; }
@media (max-width: 820px) { .checks { grid-template-columns: 1fr; } }

/* V2.1 responsive polishing: laptop / tablet / mobile */
.topbar .actions { flex-wrap: wrap; justify-content: flex-end; }
#content { max-width: 100%; }
.input, .select, .textarea, .btn { min-height: 44px; }

@media (min-width: 1400px) {
  .main { padding: 30px; }
  .grid.stats { grid-template-columns: repeat(5, minmax(190px, 1fr)); }
  .card { padding: 22px; }
}

@media (max-width: 1100px) and (min-width: 821px) {
  .app-shell { grid-template-columns: 235px 1fr; }
  .sidebar { padding: 14px; }
  .nav button { padding: 10px 9px; font-size: 13px; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .grid.stats { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 820px) {
  body { font-size: 14px; }
  .login-wrap, .quote-wrap { padding: 12px; align-items: start; }
  .login-card, .quote-card { border-radius: 20px; }
  .login-hero, .login-form { padding: 22px; }
  .login-hero h1 { font-size: 28px; }
  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    max-height: 45vh;
    overflow: auto;
    padding: 10px;
    border-left: 0;
    border-bottom: 1px solid var(--border);
  }
  .logo { padding: 8px; }
  .logo-mark { width: 34px; height: 34px; border-radius: 12px; }
  .logo-title { font-size: 13px; }
  .company-box { margin: 10px 0; }
  .nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 5px; scroll-snap-type: x mandatory; }
  .nav button { flex: 0 0 auto; width: auto; white-space: nowrap; padding: 10px 12px; scroll-snap-align: start; }
  .footer-note { display: none; }
  .main { padding: 12px; }
  .topbar { gap: 10px; margin-bottom: 14px; }
  .page-title h1 { font-size: 22px; }
  .page-title p { font-size: 12px; }
  .topbar .actions { width: 100%; justify-content: stretch; }
  .topbar .actions > .btn { flex: 1 1 150px; }
  .user-chip { width: 100%; border-radius: 16px; }
  .grid, .grid.two, .grid.stats { gap: 12px; }
  .card { border-radius: 18px; padding: 14px; }
  .stat .value { font-size: 24px; }
  .form-grid { gap: 10px; }
  .actions { gap: 6px; }
  .actions .btn { flex: 1 1 auto; }
  .checks { grid-template-columns: 1fr; }
  table { min-width: 0; }
  .table-wrap { border: 0; overflow: visible; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap th, .table-wrap td, .table-wrap tr { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--border); border-radius: 16px; margin-bottom: 10px; overflow: hidden; background: rgba(255,255,255,.035); }
  .table-wrap td { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; border-bottom: 1px solid var(--border); text-align: left; direction: rtl; }
  .table-wrap td:last-child { border-bottom: 0; }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-weight: 900; min-width: 95px; text-align: right; }
  .table-wrap td .actions { justify-content: flex-start; width: 100%; }
  .quote-header { flex-direction: column; align-items: flex-start; padding: 18px; }
  .quote-body { padding: 18px; }
}

@media (max-width: 480px) {
  .login-hero { display: none; }
  .btn { width: 100%; }
  .topbar .actions .btn { width: auto; }
  .card h3 { font-size: 16px; }
  .table-wrap td { flex-direction: column; align-items: stretch; text-align: right; }
  .table-wrap td::before { min-width: 0; }
}

/* V2.2: explicit labels outside fields + modal + mobile stability */
.field { display: grid; gap: 7px; align-content: start; }
.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding-inline: 4px;
}
.field.auto-field .input,
.field.auto-field .select,
.field.auto-field .textarea { width: 100%; }
.input::placeholder, .textarea::placeholder { color: rgba(159, 169, 192, .55); }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  backdrop-filter: blur(10px);
}
.modal-card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(145deg, rgba(22,28,45,.98), rgba(9,12,18,.98));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 28px 90px rgba(0,0,0,.55);
  padding: 18px;
}
.modal-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom: 10px; }
.modal-head h3 { margin:0; }

@media (max-width: 820px) {
  html, body { overflow-x: hidden; }
  .field label { font-size: 12px; }
  .modal-card { border-radius: 18px; padding: 14px; }
  .modal-head { align-items: flex-start; flex-direction: column; }
  .modal-head .btn { width: 100%; }
  .form-grid .btn { width: 100%; }
}
