/* =====================================================
   TOP-TECH — Main CSS
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --navy: #0f1829;
  --navy2: #1a2540;
  --navy3: #243050;
  --orange: #f36b35;
  --orange2: #ff8c5a;
  --orange-glow: rgba(243, 107, 53, 0.18);
  --bg: #f0f3f9;
  --card: #ffffff;
  --text: #1a2235;
  --muted: #6b7a94;
  --line: #e4e9f2;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --yellow: #f59e0b;
  --yellow-bg: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 4px 16px rgba(15, 24, 41, .07), 0 2px 6px rgba(15, 24, 41, .04);
  --shadow-lg: 0 20px 48px rgba(15, 24, 41, .12), 0 8px 16px rgba(15, 24, 41, .06);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --sidebar-width: 260px;
  --topbar-h: 72px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c8d0de;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9aacbf;
}

/* ── Layout ────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: #c8d8f0;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 20px 12px 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 28px;
}

.brandmark {
  width: 70px;
  height: 70px;
  border-radius: 12px;
  background: White;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  /* box-shadow: 0 4px 12px var(--orange-glow), inset 0 1px 0 rgba(255, 255, 255, .2); */
  flex-shrink: 0;
}

.brand-text strong {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.2px;
}

.brand-text small {
  display: block;
  color: #7a90b4;
  font-size: 10px;
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: .5px;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-label {
  font-size: 9.5px;
  letter-spacing: 1.8px;
  color: #4d6080;
  padding: 14px 12px 6px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: #8aa0c0;
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 0;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-btn .ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, .06);
  color: #e0eaf8;
}

.nav-btn.active {
  background: rgba(243, 107, 53, .15);
  color: #fff;
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--orange);
  border-radius: 0 3px 3px 0;
}

.side-bottom {
  margin-top: auto;
  padding: 16px 12px 0;
  color: #3d5070;
  font-size: 11px;
  line-height: 1.8;
  border-top: 1px solid rgba(255, 255, 255, .05);
  padding-top: 16px;
}

/* ── Main ──────────────────────────────────── */
.main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .04);
}

.crumb {
  font-size: 13px;
  color: var(--muted);
}

.crumb b {
  color: var(--text);
  font-weight: 600;
}

.crumb .sep {
  padding: 0 8px;
  color: #c8d0de;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-pill {
  font-size: 11px;
  background: var(--green-bg);
  color: var(--green);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-pill::before {
  content: '●';
  font-size: 8px;
}

.avatar {
  height: 38px;
  width: 38px;
  background: linear-gradient(135deg, #ffd0b8, #f36b35);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 2px 8px var(--orange-glow);
}

.mobile-menu {
  display: none;
}

/* ── Content ───────────────────────────────── */
.content {
  padding: 28px 32px 48px;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ── Page head ─────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 10.5px;
  color: var(--orange);
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.page-head h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.8px;
  margin: 0 0 6px;
}

.page-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}

/* ── Buttons ───────────────────────────────── */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover {
  background: #f8fafc;
  border-color: #cdd6e4;
}

.btn.primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  box-shadow: 0 4px 14px var(--orange-glow);
}

.btn.primary:hover {
  background: #e05e2a;
  box-shadow: 0 6px 18px var(--orange-glow);
}

.btn.danger {
  background: var(--red-bg);
  border-color: #fca5a5;
  color: var(--red);
}

.btn.danger:hover {
  background: #fee2e2;
}

.btn.success {
  background: var(--green-bg);
  border-color: #6ee7b7;
  color: var(--green);
}

.btn.sm {
  padding: 6px 11px;
  font-size: 11px;
  border-radius: 6px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Cards / Stats ─────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: box-shadow .2s, transform .2s;
}

.stat:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 10px;
}

.stat-icon {
  height: 36px;
  width: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--orange-glow);
  color: var(--orange);
  font-size: 18px;
}

.stat-icon.green {
  background: var(--green-bg);
  color: var(--green);
}

.stat-icon.blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.stat-icon.red {
  background: var(--red-bg);
  color: var(--red);
}

.stat strong {
  font-size: 30px;
  font-weight: 800;
  display: block;
  margin-bottom: 6px;
  letter-spacing: -1px;
}

.stat small {
  font-size: 11.5px;
  color: var(--muted);
}

/* ── Panel ─────────────────────────────────── */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.panel-head p {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
}

/* ── Table ─────────────────────────────────── */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  background: #f8fafd;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid #eef1f7;
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbfd;
}

/* ── Tags / Badges ─────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}

.tag.green {
  background: var(--green-bg);
  color: var(--green);
}

.tag.orange {
  background: #fff4ee;
  color: #c15a2b;
}

.tag.blue {
  background: var(--blue-bg);
  color: #2563eb;
}

.tag.gray {
  background: #f1f4f9;
  color: #6b7a94;
}

.tag.red {
  background: var(--red-bg);
  color: var(--red);
}

.tag.yellow {
  background: var(--yellow-bg);
  color: #b45309;
}

/* ── Two-col layout ────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr);
  gap: 20px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

/* ── Form ──────────────────────────────────── */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1/-1;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: #445168;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1.5px solid #dde4f0;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text);
  outline: none;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-glow);
}

.field input[readonly],
.field input:disabled {
  background: #f5f7fc;
  color: var(--muted);
}

.field small {
  font-size: 11px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 20px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

/* ── Filters ───────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters input,
.filters select {
  padding: 9px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 12.5px;
  color: #526076;
  outline: none;
  transition: border-color .15s;
}

.filters input:focus,
.filters select:focus {
  border-color: var(--orange);
}

.filters input {
  min-width: 220px;
}

/* ── Calc box ──────────────────────────────── */
.calc-box {
  background: linear-gradient(145deg, #f8fafe, #f2f6fc);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}

.calc-box h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed #dde4f0;
  font-size: 12.5px;
  color: #687589;
}

.calc-row strong {
  color: var(--text);
  font-weight: 600;
}

.calc-row:last-of-type {
  border: 0;
}

.total-row {
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #fff8f5, #fff0e8);
  border: 1.5px solid #fdd6c0;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-row span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.total-row strong {
  font-size: 26px;
  font-weight: 800;
  color: var(--orange);
}

/* ── Alert / Notice ────────────────────────── */
.notice {
  padding: 13px 16px;
  background: var(--yellow-bg);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 14px;
}

.notice.info {
  background: var(--blue-bg);
  border-color: #93c5fd;
  color: #1e40af;
}

.notice.success {
  background: var(--green-bg);
  border-color: #6ee7b7;
  color: #065f46;
}

.notice.danger {
  background: var(--red-bg);
  border-color: #fca5a5;
  color: #991b1b;
}

/* ── Mini cards ────────────────────────────── */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mini {
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fafbfd;
}

.mini small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.mini strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-top: 6px;
}

/* ── Toast ─────────────────────────────────── */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--navy2);
  color: white;
  padding: 13px 20px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition: .25s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error-toast {
  background: #7f1d1d;
}

.toast.success-toast {
  background: #064e3b;
}

/* ── Work type checkbox group ──────────────── */
.check-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1.5px solid #dde4f0;
  border-radius: var(--radius-sm);
  background: #fafbfd;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid #e0e8f4;
  background: #fff;
  transition: all .15s;
  user-select: none;
}

.check-item:hover {
  border-color: var(--orange);
  background: var(--orange-glow);
}

.check-item input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--orange);
}

.check-item.checked {
  border-color: var(--orange);
  background: #fff4ee;
  font-weight: 600;
  color: #c15a2b;
}

/* ── Section divider ───────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 14px;
}

.section-divider .sdlabel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #445168;
  white-space: nowrap;
}

.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Image upload ──────────────────────────── */
.img-upload-area {
  border: 2px dashed #d0d9ea;
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafbfd;
  position: relative;
}

.img-upload-area:hover {
  border-color: var(--orange);
  background: var(--orange-glow);
}

.img-upload-area input[type=file] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.img-upload-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.img-upload-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.img-upload-sub {
  font-size: 11px;
  color: #9aacbf;
  margin-top: 4px;
}

.img-preview-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
}

.img-preview-wrap img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  border: 1.5px solid var(--line);
}

.img-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  border: 0;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* ── Empty state ───────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 13px;
  color: var(--muted);
}

/* ── Price matrix ──────────────────────────── */
.pm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.pm-chip.cutting {
  background: #fff0e8;
  color: #c15a2b;
}

.pm-chip.piercing {
  background: var(--blue-bg);
  color: #1d4ed8;
}

.pm-chip.both {
  background: #f3f0ff;
  color: #6d28d9;
}

/* ── Order detail / Invoice ────────────────── */
.order-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy3) 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  color: #fff;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.order-hero::before {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--orange-glow) 0%, transparent 70%);
}

.order-hero .job-no {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
}

.order-hero .job-meta {
  font-size: 13px;
  color: #8aa0c0;
  margin-top: 6px;
}

.order-hero .job-status {
  position: absolute;
  top: 24px;
  right: 24px;
}

.invoice-wrap {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

/* ── Image gallery ─────────────────────────── */
.img-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.img-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--line);
}

.img-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.img-card-label {
  padding: 10px 14px;
  background: #f8fafd;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Print styles ──────────────────────────── */
@media print {

  .sidebar,
  .topbar,
  .btn,
  .page-head .btn,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .invoice-wrap {
    box-shadow: none;
    padding: 0;
  }

  .content {
    padding: 0;
  }

  .page {
    display: block !important;
  }

  .panel {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 1200px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .three-col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .sidebar {
    width: 220px;
  }

  .content {
    padding: 20px 16px;
  }
}

@media (max-width: 700px) {
  .app {
    display: block;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform .25s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding-top: var(--topbar-h);
  }

  .topbar {
    position: fixed;
    width: 100%;
  }

  .mobile-menu {
    display: inline-flex !important;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat {
    padding: 14px;
  }

  .three-col {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }

  .page-head {
    flex-direction: column;
    gap: 12px;
  }

  .img-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    grid-template-columns: 1fr;
  }
}