:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 12px; border: 1px solid transparent;
  font-size: 15px; font-weight: 600; transition: all .15s ease; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: #f1f5f9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 17px;
}
.brand .logo-sub { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Hero */
.hero {
  padding: 72px 0 56px;
  background: radial-gradient(1200px 500px at 50% -10%, #dbeafe 0%, transparent 60%), var(--bg);
}
.hero-inner { text-align: center; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: 44px; line-height: 1.15; margin: 0 0 18px; letter-spacing: -0.02em; }
.hero h1 .hl { color: var(--primary); }
.hero p.sub { font-size: 18px; color: var(--text-muted); margin: 0 0 30px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 40px; justify-content: center; margin-top: 44px; flex-wrap: wrap; }
.stat { text-align: center; }
.stat .num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat .lbl { font-size: 13px; color: var(--text-muted); }

/* Sections */
.section { padding: 56px 0; }
.section-head { text-align: center; margin-bottom: 36px; }
.section-head h2 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.01em; }
.section-head p { color: var(--text-muted); margin: 0; font-size: 16px; }

/* Services grid */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.service-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 15px;
  transition: all .15s ease; box-shadow: var(--shadow);
}
.service-tile:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.service-tile .ic {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}

/* Areas */
.areas-wrap { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.area-chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; color: var(--text-muted); font-weight: 500;
}

/* Steps */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 22px; box-shadow: var(--shadow); position: relative;
}
.step .n {
  width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 14px;
}
.step h3 { margin: 0 0 6px; font-size: 17px; }
.step p { margin: 0; color: var(--text-muted); font-size: 14px; }

/* Cards (orders/masters) */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.order-card { display: flex; flex-direction: column; gap: 10px; }
.order-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.order-title { font-weight: 700; font-size: 16px; }
.order-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text-muted); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}
.badge-new { background: #dcfce7; color: #166534; }
.badge-inprogress { background: #dbeafe; color: #1e40af; }
.badge-done { background: #f1f5f9; color: #475569; }
.badge-canceled { background: #fee2e2; color: #991b1b; }
.badge-hot { background: #fef3c7; color: #92400e; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text); transition: border .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.textarea { resize: vertical; min-height: 90px; }

/* Chip multiselect */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; background: #fff; color: var(--text); transition: all .12s;
}
.chip:hover { border-color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease;
}
.modal {
  background: #fff; border-radius: 18px; padding: 28px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal h3 { margin: 0 0 18px; font-size: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 500; z-index: 200; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
#toast.err { background: var(--danger); }

/* Auth / empty states */
.auth-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-box {
  background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 40px 34px;
  max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow-lg);
}
.auth-box h2 { margin: 0 0 8px; }
.auth-box p { color: var(--text-muted); margin: 0 0 24px; font-size: 15px; }
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.role-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 20px 14px; text-align: center;
  cursor: pointer; transition: all .15s; background: #fff;
}
.role-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.role-card .em { font-size: 30px; margin-bottom: 8px; }
.role-card .t { font-weight: 700; margin-bottom: 4px; }
.role-card .d { font-size: 12px; color: var(--text-muted); }

.empty {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius); background: #fff;
}
.empty .em { font-size: 34px; margin-bottom: 10px; }

/* App layout */
.app-shell { max-width: 1000px; margin: 0 auto; padding: 24px 20px 80px; }
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.app-user { display: flex; align-items: center; gap: 12px; }
.app-user .avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
}
.app-user .uname { font-weight: 700; }
.app-user .urole { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-muted);
  border: none; background: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-list { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* Billing */
.bill-stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; box-shadow: var(--shadow);
}
.bill-stat .v { font-size: 30px; font-weight: 800; color: var(--primary); }
.bill-stat .l { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.plan-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
}
.plan-card .plan-title { font-weight: 700; font-size: 17px; }
.plan-card .plan-price { font-size: 22px; font-weight: 800; color: var(--primary); }
.plan-card .plan-desc { font-size: 13px; color: var(--text-muted); }

.footer { border-top: 1px solid var(--border); padding: 32px 0; margin-top: 40px; color: var(--text-muted); font-size: 13px; text-align: center; }

.spinner {
  width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hidden { display: none !important; }
