:root {
  --navy: #123a4d;
  --blue: #1976d2;
  --blue-dark: #125199;
  --accent: #ea7c1e;
  --accent-dark: #c4650f;
  --success: #1f9254;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --text: #182233;
  --text-light: #667085;
  --border: #e6e9f0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 16px rgba(10, 22, 40, 0.06);
  --shadow-lg: 0 16px 40px rgba(10, 22, 40, 0.16);
  --font-heading: "Sora", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--font-heading); }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy), #1c5670);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  display: inline-flex;
  background: var(--navy);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 26px;
}
.login-logo span { padding: 8px 10px; font-weight: 700; }
.login-logo .s1 { color: #fff; font-family: var(--font-heading); font-weight: 700; }
.login-logo .s2 { background: var(--accent); color: #fff; }
.login-box h2 { font-size: 20px; margin-bottom: 6px; }
.login-box p.sub { font-size: 13px; color: var(--text-light); margin-bottom: 22px; }
.login-error {
  background: #fdecea; color: #b3261e; border: 1px solid #f5c6c2;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; display: none;
}

/* ---------- Form controls (shared) ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.12);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px; border-radius: var(--radius-sm); border: none;
  font-weight: 700; font-size: 14px; transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); }
.btn-outline { background: none; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-danger { background: #fdecea; color: #b3261e; }
.btn-danger:hover { background: #f9d5d1; }

/* ---------- App shell ---------- */
.app-shell { display: none; min-height: 100vh; }
.app-shell.visible { display: flex; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--navy); color: #cbd5e1;
  display: flex; flex-direction: column; padding: 22px 0;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 22px 22px; }
.sidebar .brand-logo {
  display: inline-flex; background: var(--navy); border-radius: 5px; overflow: hidden; font-weight: 700; font-size: 13px;
}
.sidebar .brand-logo span { padding: 5px 7px; }
.sidebar .brand-logo .s1 { color: #fff; font-family: var(--font-heading); font-weight: 700; }
.sidebar .brand-logo .s2 { background: var(--accent); color: #fff; }
.sidebar .brand small { display: block; font-size: 11px; color: #8ea0b5; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 22px; font-size: 14px; font-weight: 600;
  color: #b6c2d9; border-left: 3px solid transparent; transition: background 0.2s, color 0.2s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.08); color: #fff; border-left-color: var(--accent); }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 800;
  margin-left: auto;
}
.sidebar-footer { margin-top: auto; padding: 16px 22px 0; }
.admin-name { font-size: 13px; color: #8ea0b5; margin-bottom: 10px; }
.sidebar-footer .btn-outline { border-color: rgba(255, 255, 255, 0.25); color: #cbd5e1; }
.sidebar-footer .btn-outline:hover { border-color: #fff; color: #fff; }

.mobile-topbar { display: none; }
.mobile-topbar .brand-logo {
  display: inline-flex; background: var(--navy); border-radius: 5px; overflow: hidden; font-weight: 700; font-size: 13px;
}
.mobile-topbar .brand-logo span { padding: 5px 7px; }
.mobile-topbar .brand-logo .s1 { color: #fff; font-family: var(--font-heading); font-weight: 700; }
.mobile-topbar .brand-logo .s2 { background: var(--accent); color: #fff; }
.mobile-menu-btn {
  background: none; border: none; color: #fff; padding: 4px; display: flex; align-items: center; justify-content: center;
}
.mobile-menu-btn svg { width: 26px; height: 26px; }
.sidebar-close-btn {
  display: none; background: none; border: none; color: #fff; font-size: 26px; line-height: 1; padding: 0 4px; cursor: pointer;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10, 22, 40, 0.55); z-index: 999;
}
.sidebar-overlay.open { display: block; }

.main-content { flex: 1; min-width: 0; padding: 30px 36px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; }
.page-header p { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .stat-label { font-size: 12px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; font-family: var(--font-heading); color: var(--navy); margin-top: 6px; }

/* ---------- Dashboard ---------- */
.dash-row-2 { grid-template-columns: repeat(2, 1fr); max-width: 480px; }
.dash-section-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-light); margin: 4px 0 10px;
}
.dash-grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.dash-panel-title { font-size: 14px; font-family: var(--font-heading); color: var(--navy); margin-bottom: 14px; }
.trend-chart { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; }
.trend-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bar {
  width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--blue), var(--blue-dark));
  border-radius: 5px 5px 0 0; min-height: 3px; transition: height 0.3s ease;
}
.trend-label { font-size: 11px; color: var(--text-light); margin-top: 8px; }
.trend-value { font-size: 10.5px; color: var(--navy); font-weight: 700; margin-bottom: 4px; }

.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.panel-toolbar input[type="search"] {
  padding: 9px 14px; border: 1.5px solid var(--border); border-radius: 20px; font-size: 13px; min-width: 220px; outline: none;
}

.auth-tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--border); }
.auth-tab {
  flex: 1; background: none; border: none; padding: 9px 10px;
  font-size: 13px; font-weight: 600; color: var(--text-light); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1.5px;
}
.auth-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.bulk-action-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; background: #fff7ed; border-bottom: 1px solid var(--border);
}
.bulk-action-bar span { font-size: 13px; font-weight: 600; color: var(--navy); }
.bulk-action-bar input[type="number"] { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 560px; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-light);
  background: #fafbfd; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }

.prod-thumb {
  width: 44px; height: 44px; border-radius: 8px; background: linear-gradient(135deg, #eaf1fb, #dbe8fa);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-cell { display: flex; align-items: center; gap: 12px; }
.prod-name { font-weight: 700; }
.prod-meta { font-size: 12px; color: var(--text-light); }

.badge-pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: 20px;
  background: #eaf1fb; color: var(--blue); text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-pill.green { background: #e6f7ec; color: var(--success); }
.badge-pill.red { background: #fdecea; color: #b3261e; }
.badge-pill.gray { background: #f0f1f4; color: var(--text-light); }

.status-select {
  padding: 7px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
}

.row-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center; color: var(--text-light); transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.icon-btn.danger:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

.empty-row td { text-align: center; padding: 40px 20px; color: var(--text-light); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 22, 40, 0.55);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 620px;
  padding: 28px 30px; position: relative; box-shadow: var(--shadow-lg); max-height: 92vh; overflow-y: auto;
}
.modal-box h2 { font-size: 19px; margin-bottom: 4px; }
.modal-box .modal-sub { font-size: 13px; color: var(--text-light); margin-bottom: 20px; }
.modal-close { position: absolute; top: 18px; right: 18px; background: none; border: none; font-size: 22px; color: var(--text-light); }

.specs-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px; }
.spec-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
.spec-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.spec-row button { background: none; border: none; color: var(--accent); font-size: 16px; }

.image-upload-box {
  border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center;
  cursor: pointer; margin-bottom: 16px; position: relative;
}
.image-upload-box:hover { border-color: var(--blue); }
.image-upload-box img { max-height: 120px; margin: 0 auto 8px; border-radius: 6px; }
.image-upload-box .hint { font-size: 12.5px; color: var(--text-light); }
.image-upload-box input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.image-upload-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.image-tile {
  width: 84px; height: 84px; border-radius: var(--radius-sm); overflow: hidden; position: relative;
  border: 1.5px solid var(--border); background: var(--bg);
}
.image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-tile .tile-remove-btn {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(20, 26, 38, 0.7); color: #fff; border: none; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.image-tile .tile-remove-btn:hover { background: #b3261e; }
.image-tile.tile-primary::after {
  content: "Main"; position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0; text-align: center;
  font-size: 10px; font-weight: 700; color: #fff; background: rgba(20, 26, 38, 0.65);
}
.image-tile.add-tile {
  border: 2px dashed var(--border); background: none; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px; cursor: pointer; color: var(--text-light); font-size: 11px; text-align: center;
}
.image-tile.add-tile:hover { border-color: var(--blue); color: var(--blue); }
.image-tile.add-tile .plus { font-size: 22px; line-height: 1; }
.image-upload-hint { font-size: 12px; color: var(--text-light); margin-bottom: 16px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 2000; opacity: 0; transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }
.content-type-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Technician list (Service Bookings tab) ---------- */
.technician-list { display: flex; flex-wrap: wrap; gap: 10px; }
.technician-card {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; min-width: 200px;
}
.technician-card .t-name { font-weight: 700; font-size: 13.5px; }
.technician-card .t-phone { font-size: 12px; color: var(--text-light); }
.technician-card .icon-btn { margin-left: auto; width: 26px; height: 26px; }
.booking-assign { display: flex; gap: 6px; align-items: center; }
.booking-assign select { padding: 6px 8px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; }

/* ---------- Order detail modal ---------- */
.od-section { margin-bottom: 20px; }
.od-section h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-light); margin-bottom: 10px; }
.od-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.od-address { font-size: 13.5px; line-height: 1.7; background: #fafbfd; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.od-items-table { width: 100%; min-width: 0; border-collapse: collapse; }
.od-items-table td { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.od-items-table tr:last-child td { border-bottom: none; }
.od-timeline { list-style: none; }
.od-timeline li { display: flex; gap: 10px; align-items: baseline; font-size: 13px; padding: 6px 0; }
.od-timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.od-timeline .time { color: var(--text-light); font-size: 12px; margin-left: auto; }
.od-total-row { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 6px; }

@media (max-width: 900px) {
  .app-shell.visible { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--navy); padding: 14px 18px; position: sticky; top: 0; z-index: 500;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 260px; max-width: 82vw;
    flex-direction: column; align-items: stretch; padding: 22px 0 16px; overflow-y: auto;
    transform: translateX(-100%); transition: transform 0.25s ease; z-index: 1000; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand { display: flex; justify-content: space-between; align-items: center; padding: 0 18px 22px; }
  .sidebar-close-btn { display: block; }
  .sidebar-footer { display: block; }
  .nav-item { padding: 12px 22px; border-left: 3px solid transparent; border-bottom: none; white-space: normal; }
  .nav-item.active { border-left-color: var(--accent); border-bottom-color: transparent; }
  .main-content { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .od-grid { grid-template-columns: 1fr; }
  .dash-grid-2 { grid-template-columns: 1fr; }
  .dash-row-2 { max-width: none; }
}

@media (max-width: 600px) {
  .main-content { padding: 14px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn { width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 21px; }
  .panel-toolbar { flex-direction: column; align-items: stretch; }
  .panel-toolbar input[type="search"] { min-width: 0; width: 100%; }
  .modal-box { padding: 20px 18px; }
  .login-box { padding: 28px 22px; }
  .spec-row { grid-template-columns: 1fr 1fr; }
  .spec-row button { grid-column: 1 / -1; justify-self: end; }

  table { min-width: 420px; }
  thead th { padding: 9px 10px; font-size: 10.5px; }
  tbody td { padding: 8px 10px; font-size: 12.5px; }
  .prod-thumb { width: 32px; height: 32px; border-radius: 6px; }
  .prod-cell { gap: 8px; }
  .products-table .prod-cell > div:last-child { min-width: 0; }
  .products-table .prod-name {
    font-size: 12.5px; line-height: 1.3; max-width: 130px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .products-table .prod-meta { font-size: 10.5px; }
  .icon-btn { width: 28px; height: 28px; }
  .icon-btn svg { width: 14px; height: 14px; }
  .row-actions { gap: 5px; }
  .products-table th:nth-child(5), .products-table td:nth-child(5),
  .products-table th:nth-child(6), .products-table td:nth-child(6) { display: none; }
}
