@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('../fonts/BricolageGrotesque_24pt-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Neue';
  src: url('../fonts/HelveticaNeueLight.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Neue';
  src: url('../fonts/HelveticaNeueMedium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Neue';
  src: url('../fonts/HelveticaNeueBold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Neue';
  src: url('../fonts/HelveticaNeueHeavy.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --sml-orange: #f96321;
  --sml-orange-dark: #e05518;
  --sml-orange-soft: #fff1e9;
  --sml-bg: #f3f4f6;
  --sml-text: #1f2937;
  --sml-muted: #6b7280;
  --sml-border: #e5e7eb;
  --sml-success: #16a34a;
  --sml-success-soft: #dcfce7;
  --sml-danger: #dc2626;
  --sml-danger-soft: #fee2e2;
  --sml-warning: #b45309;
  --sml-warning-soft: #fef3c7;
  --sml-secondary: #4b5563;
  --sml-secondary-soft: #f3f4f6;
  --sml-radius: 9px;
  --sml-radius-sm: 6px;
  --sml-radius-lg: 1rem;
  /* Display font — headings, brand, page titles, big numbers. Only a Bold cut is
     loaded (that's all we have), which is fine since headings are always bold anyway. */
  --sml-font-display: 'Bricolage Grotesque', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  /* Body font — everything else: text, buttons, tables, forms, nav. */
  --sml-font: 'Helvetica Neue', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --sml-sidebar-w: 260px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sml-font);
  font-weight: 500;
  background: var(--sml-bg);
  color: var(--sml-text);
  overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--sml-font-display); font-weight: 700; }
img, svg { max-width: 100%; }
a { color: var(--sml-orange); text-decoration: none; }

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sml-sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--sml-border);
  display: flex;
  flex-direction: column;
}
.brand { padding: 1.25rem; border-bottom: 1px solid var(--sml-border); display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.brand-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.brand a { color: var(--sml-text); font-weight: 800; font-size: 1.1rem; font-family: var(--sml-font-display); white-space: nowrap; }
.brand span { color: var(--sml-orange); }
.brand small { display: block; color: var(--sml-muted); text-transform: uppercase; font-size: .7rem; letter-spacing: .06em; white-space: nowrap; }
.sidebar-close {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--sml-radius-sm);
  border: 1px solid var(--sml-border); background: #fff; color: var(--sml-muted); cursor: pointer;
}
.sidebar-close:hover { color: var(--sml-danger); border-color: var(--sml-danger); }
.sidebar-close svg { width: 18px; height: 18px; }
.sidebar nav { padding: .75rem; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; border-radius: 999px; color: var(--sml-text); margin-bottom: .25rem; font-size: .9rem; font-weight: 600;
}
.sidebar nav a:hover { background: var(--sml-orange-soft); color: var(--sml-orange); }
.sidebar nav a.active { background: var(--sml-orange); color: #fff; }
.sidebar nav em {
  background: #fff; color: var(--sml-orange); border-radius: 999px; padding: 0 .45rem; font-style: normal; font-size: .7rem;
}
.sidebar nav a.active em { background: rgba(255,255,255,.25); color: #fff; }

.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: flex-end; gap: 1rem; padding: .75rem 1.5rem;
  background: rgba(255,255,255,.9); border-bottom: 1px solid var(--sml-border); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
.menu-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--sml-radius); border: 1px solid var(--sml-border);
  background: #fff; color: var(--sml-text); cursor: pointer; margin-right: auto; flex-shrink: 0;
}
.menu-toggle svg { width: 20px; height: 20px; }

.userchip { display: flex; gap: .6rem; align-items: center; background: var(--sml-bg); border: 1px solid var(--sml-border); border-radius: 999px; padding: .35rem .8rem; min-width: 0; }
a.userchip { text-decoration: none; color: inherit; }
a.userchip:hover { background: #eceef1; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--sml-orange); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.userchip strong { display: block; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.userchip small { color: var(--sml-muted); text-transform: uppercase; font-size: .65rem; }

.topbar-signout { margin: 0; }
.topbar-signout button {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--sml-border); background: #fff; color: var(--sml-muted);
  padding: .55rem 1rem; border-radius: var(--sml-radius); font-size: .85rem; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: border-color .15s, color .15s;
}
.topbar-signout button:hover { border-color: var(--sml-danger); color: var(--sml-danger); }
.topbar-signout svg { width: 15px; height: 15px; flex-shrink: 0; }

.content { padding: 1.5rem; max-width: 100%; overflow-x: hidden; }
.page-title { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: clamp(1.3rem, 3.4vw, 1.75rem); }
.page-title p { margin: .35rem 0 0; color: var(--sml-muted); font-size: .9rem; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------- Cards / sections / tables ---------- */
.card, .metric, .section, .table-wrap, .auth-card {
  background: #fff; border: 1px solid var(--sml-border); border-radius: var(--sml-radius-lg); box-shadow: 0 1px 2px rgba(0,0,0,.04);
  min-width: 0;
}
.metric { padding: 1.1rem; overflow: hidden; }
.metric label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--sml-muted); font-weight: 700; }
.metric strong { display: block; margin-top: .4rem; font-size: 1.8rem; overflow-wrap: break-word; font-family: var(--sml-font-display); }
.section { overflow: hidden; margin-bottom: 1rem; }
.section h3 {
  margin: 0; padding: .85rem 1.1rem; background: var(--sml-orange-soft); color: var(--sml-orange);
  text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.section .body { padding: 1.1rem; overflow-wrap: break-word; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: .85rem 1rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sml-muted); background: #f9fafb; border-bottom: 1px solid var(--sml-border); white-space: nowrap; }
td { padding: .85rem 1rem; border-bottom: 1px solid var(--sml-border); vertical-align: middle; white-space: nowrap; }
.table-wrap table { min-width: max-content; }
td.wrap-col, th.wrap-col { white-space: normal; overflow-wrap: break-word; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: var(--sml-radius); padding: .6rem 1.1rem; font-size: .85rem; font-weight: 700;
  font-family: inherit; line-height: 1.2; border: 1px solid transparent; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap; max-width: 100%;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--sml-orange); color: #fff; }
.btn-primary:hover { background: var(--sml-orange-dark); color: #fff; }
.btn-secondary { background: var(--sml-secondary-soft); color: var(--sml-secondary); border-color: var(--sml-border); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-outline { background: #fff; border-color: var(--sml-border); color: var(--sml-text); }
.btn-outline:hover { border-color: var(--sml-orange); color: var(--sml-orange); }
.btn-ghost { background: transparent; color: var(--sml-muted); }
.btn-ghost:hover { background: var(--sml-bg); color: var(--sml-text); }
.btn-success { background: var(--sml-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--sml-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--sml-warning-soft); color: var(--sml-warning); border-color: #fde68a; }
.btn-warning:hover { background: #fde68a; }
.btn-sm { padding: .4rem .75rem; font-size: .78rem; border-radius: var(--sml-radius-sm); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; border-radius: 999px; padding: .25rem .65rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-green { background: var(--sml-success-soft); color: #166534; }
.badge-orange { background: var(--sml-orange-soft); color: var(--sml-orange); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-red { background: var(--sml-danger-soft); color: #b91c1c; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: .9rem; font-size: .85rem; font-weight: 600; min-width: 0; }
label.field span { color: var(--sml-orange); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=file], select, textarea {
  width: 100%; margin-top: .35rem; border: 1px solid var(--sml-border); border-radius: var(--sml-radius); padding: .65rem .8rem; font: inherit; font-family: inherit;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(249,99,33,.25); border-color: var(--sml-orange); }
.checkboxes { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.checkboxes label { display: flex; gap: .5rem; align-items: center; border: 1px solid var(--sml-border); border-radius: var(--sml-radius); padding: .55rem .7rem; font-weight: 500; font-size: .85rem; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 2.75rem; }
.password-toggle {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer; color: var(--sml-muted);
  display: flex; align-items: center; justify-content: center; padding: .4rem; border-radius: var(--sml-radius-sm);
}
.password-toggle:hover { color: var(--sml-text); background: var(--sml-bg); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at top, #fff1e9, #f3f4f6 55%);
  padding: 1rem;
}
.auth-card { width: 100%; max-width: 460px; padding: 2rem; }
.auth-card.wide { max-width: 720px; }
.auth-card h1 { margin: 0 0 .25rem; text-align: center; font-size: clamp(1.3rem, 4vw, 1.6rem); }
.auth-card .sub { text-align: center; color: var(--sml-muted); margin-bottom: 1.25rem; }

/* ---------- Misc ---------- */
.flash { border-radius: var(--sml-radius); padding: .75rem 1rem; margin-bottom: 1rem; font-size: .9rem; overflow-wrap: break-word; }
.flash-success { background: var(--sml-success-soft); color: #166534; }
.flash-error { background: var(--sml-danger-soft); color: #b91c1c; }
.flash-info { background: #dbeafe; color: #1d4ed8; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--sml-muted); }
.quote-card { padding: 1.1rem; min-width: 0; }
.quote-card h3 { margin: 0 0 .5rem; overflow-wrap: break-word; }
.detail-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0,1fr)); }
.detail-grid dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sml-muted); font-weight: 700; }
.detail-grid dd { margin: .25rem 0 0; overflow-wrap: break-word; }
.invoice-doc { max-width: 800px; margin: 0 auto; padding: 2rem; background: #fff; border: 1px solid var(--sml-border); border-radius: var(--sml-radius-lg); line-height: 1.6; }
.invoice-doc section.grid > div > div { margin-top: .3rem; overflow-wrap: break-word; }
.invoice-doc section.grid > div > div:first-child { margin-top: 0; }
.invoice-doc section.grid { row-gap: 1.5rem; }
.invoice-doc table td, .invoice-doc table th { white-space: normal; overflow-wrap: break-word; }

/* =========================================================
   Responsive breakpoints
   ========================================================= */

/* Large desktop: keep content from stretching too thin/wide */
@media (min-width: 1441px) {
  .content { padding: 2rem 2.5rem; }
}

/* Sidebar becomes an off-canvas drawer from 1024px down */
@media (max-width: 1024px) {
  .menu-toggle { display: inline-flex; }
  /*.brand small { display: none; }*/
  .sidebar-close { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 40;
    transform: translateX(-100%); transition: transform .25s ease; width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(17,24,39,.45);
    opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 30;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .content { padding: 1.25rem; }
  .topbar { padding: .65rem 1rem; }
  .userchip strong { max-width: 110px; }
}

@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content { padding: 1rem; }
  .page-title { align-items: flex-start; }
  .auth-card { padding: 1.5rem; }
  .invoice-doc { padding: 1.25rem; }
  .btn { padding: .6rem .9rem; font-size: .82rem; }
  th, td { padding: .65rem .75rem; }
}

@media (max-width: 480px) {
  .content { padding: .85rem; }
  .brand { padding: 1rem; }
  .topbar { padding: .6rem .75rem; gap: .6rem; }
  .userchip { padding: .3rem .6rem; }
  .userchip strong { max-width: 90px; font-size: .8rem; }
  .userchip small { display: none; }
  .topbar-signout button { padding: .5rem .65rem; }
  .topbar-signout button span.signout-label { display: none; }
  .invoice-doc { padding: 1rem; }
  .auth-card { padding: 1.25rem; }
  .metric strong { font-size: 1.5rem; }
}

@media print {
  .sidebar, .topbar, .print-hide, .topbar-signout, .menu-toggle, .sidebar-backdrop { display: none !important; }
  .shell, .main, .content { display: block; background: #fff; }
  .invoice-doc { border: 0; box-shadow: none; }
}
