/* ==========================================================================
   Jaysmart Partners — Design System
   Signature: "signal" — an ascending 4-bar network glyph used as the one
   recurring motif (active nav marker, sidebar watermark, focus accents),
   grounded in the fact this is a telecom distribution console.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  /* Color */
  --bg: #F5F3EF;
  --surface: #FFFFFF;
  --soft: #FBFAF8;
  --ink: #1C1512;
  --muted: #857A72;
  --line: #E8E1D9;

  --primary: #E4002B;
  --primary-dark: #55000E;
  --primary-deep: #2E0008;
  --primary-glow: #FF4D6A;
  --primary-soft: #FDECEE;

  --ok: #0E7A4C;
  --ok-soft: #E7F6EE;
  --ok-line: #BEE8D2;

  --warn: #A85A00;
  --warn-soft: #FFF3E0;
  --warn-line: #F3D8A6;

  --gold: #C6941A;

  /* Type */
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Shape + shadow */
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(46, 0, 8, 0.04), 0 1px 1px rgba(46, 0, 8, 0.03);
  --shadow: 0 2px 6px rgba(46, 0, 8, 0.05), 0 16px 40px -16px rgba(46, 0, 8, 0.16);
  --shadow-lg: 0 24px 60px -20px rgba(46, 0, 8, 0.28);

  --sidebar-w: 284px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--primary);
  color: #fff;
}

a {
  color: var(--primary-dark);
}

:focus-visible {
  outline: 3px solid var(--primary-glow);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--primary-deep);
}

h1 { font-size: 30px; letter-spacing: -0.02em; }
h2 { font-size: 19px; margin-bottom: 4px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }

code {
  font-family: var(--font-mono);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  background:
    radial-gradient(560px 420px at 12% -8%, rgba(255, 77, 106, 0.35), transparent 60%),
    radial-gradient(640px 520px at 108% 108%, rgba(255, 77, 106, 0.22), transparent 55%),
    linear-gradient(150deg, var(--primary-deep) 0%, var(--primary-dark) 46%, var(--primary) 130%);
  overflow: hidden;
}

.login-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--signal-watermark);
  background-repeat: repeat;
  background-size: 220px 160px;
  opacity: 0.10;
  pointer-events: none;
}

.login-card {
  position: relative;
  width: min(430px, 100%);
  display: grid;
  gap: 20px;
  border-radius: 20px;
  background: var(--surface);
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-card h1 {
  font-size: 24px;
}

.login-card .brand-row small {
  color: var(--muted);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row.vertical {
  align-items: flex-start;
  flex-direction: column;
}

.brand-row strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-row small {
  display: block;
  color: #FFC9CE;
  font-size: 12px;
}

.logo-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  background: #fff;
  padding: 7px 9px;
  box-shadow: var(--shadow-sm);
}

.logo-pill.stacked {
  border-radius: 18px;
  flex-direction: column;
  padding: 9px;
}

.logo-pill img {
  width: 92px;
  height: 42px;
  object-fit: contain;
  border-radius: 999px;
}

.logo-pill.stacked img {
  width: 118px;
  border-radius: 10px;
}

form,
.panel {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: #3C332D;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--ink);
  padding: 10px 13px;
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
  resize: vertical;
}

input:hover, select:hover, textarea:hover {
  border-color: #D8CCC2;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

button,
.secondary,
.nav-link {
  border: 0;
  border-radius: var(--radius-sm);
  min-height: 42px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, filter 0.12s ease;
}

.primary {
  background: linear-gradient(155deg, var(--primary) 0%, #C4001F 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(46, 0, 8, 0.15), 0 10px 22px -10px rgba(228, 0, 43, 0.55);
}

.primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(46, 0, 8, 0.18), 0 14px 26px -10px rgba(228, 0, 43, 0.6);
}

.primary:active {
  transform: translateY(0);
}

.secondary {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--primary-dark);
}

.secondary:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.danger {
  background: #FDECEC;
  color: #B42318;
}

.danger:hover {
  background: #FBD5D5;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px 22px;
  background:
    radial-gradient(340px 260px at 8% 0%, rgba(255, 77, 106, 0.30), transparent 60%),
    linear-gradient(178deg, var(--primary-dark) 0%, var(--primary-deep) 78%);
  color: #fff5f5;
  overflow: hidden;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--signal-watermark);
  background-repeat: repeat;
  background-size: 190px 140px;
  opacity: 0.07;
  pointer-events: none;
}

.sidebar > * {
  position: relative;
}

.menu-toggle {
  display: none;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  position: relative;
  justify-content: flex-start;
  color: #FBD9DC;
  background: transparent;
  padding: 11px 14px 11px 30px;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  border-radius: 10px;
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background-image: var(--signal-icon-dim);
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link:hover::before {
  opacity: 0.85;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.nav-link.active::before {
  background-image: var(--signal-icon-bright);
  opacity: 1;
}

.workspace {
  margin-left: var(--sidebar-w);
  padding: 34px 36px 60px;
  max-width: 1400px;
}

.topbar,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.eyebrow::before {
  content: "";
  width: 11px;
  height: 11px;
  background-image: var(--signal-icon-primary);
  background-repeat: no-repeat;
  background-size: contain;
}

.summary-grid,
.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bottom-grid {
  align-items: end;
}

.product-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 14px;
  align-items: end;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 20px 20px 18px;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), transparent 85%);
  opacity: 0.7;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.metric strong {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--primary-deep);
}

.metric.dark {
  background:
    radial-gradient(220px 160px at 100% 0%, rgba(255, 77, 106, 0.35), transparent 65%),
    linear-gradient(160deg, var(--primary-dark), var(--primary-deep));
  color: #fff;
  border-color: transparent;
}

.metric.dark::before {
  background: linear-gradient(90deg, #FF8FA0, transparent 85%);
}

.metric.dark span {
  color: #FBC7CC;
}

.metric.dark strong {
  color: #fff;
}

.panel {
  margin-top: 18px;
  padding: 26px 26px 28px;
}

.panel h2 {
  font-size: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1.5px solid var(--line);
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--soft);
}

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

td:has(> code),
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.empty-row td {
  color: var(--muted);
  padding: 30px;
  text-align: center;
  font-style: normal;
}

.line-qty {
  max-width: 100px;
  font-family: var(--font-mono);
}

.grand-total {
  margin-left: auto;
  text-align: right;
}

.grand-total span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.grand-total strong {
  font-family: var(--font-mono);
  color: var(--primary-dark);
  font-size: 30px;
  font-weight: 600;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  margin-bottom: 16px;
  font-weight: 700;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.alert.success {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok);
}

.alert.danger {
  border-color: #F6C9C7;
  background: #FDF0EF;
  color: #B42318;
}

:root {
  --signal-icon-dim: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16'%3E%3Crect x='0' y='10' width='3.4' height='6' rx='1' fill='white'/%3E%3Crect x='5.6' y='7' width='3.4' height='9' rx='1' fill='white'/%3E%3Crect x='11.2' y='4' width='3.4' height='12' rx='1' fill='white'/%3E%3Crect x='16.6' y='0' width='3.4' height='16' rx='1' fill='white'/%3E%3C/svg%3E");
  --signal-icon-bright: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16'%3E%3Crect x='0' y='10' width='3.4' height='6' rx='1' fill='%23FFC9CE'/%3E%3Crect x='5.6' y='7' width='3.4' height='9' rx='1' fill='%23FFC9CE'/%3E%3Crect x='11.2' y='4' width='3.4' height='12' rx='1' fill='white'/%3E%3Crect x='16.6' y='0' width='3.4' height='16' rx='1' fill='white'/%3E%3C/svg%3E");
  --signal-icon-primary: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16'%3E%3Crect x='0' y='10' width='3.4' height='6' rx='1' fill='%23E4002B'/%3E%3Crect x='5.6' y='7' width='3.4' height='9' rx='1' fill='%23E4002B'/%3E%3Crect x='11.2' y='4' width='3.4' height='12' rx='1' fill='%23E4002B'/%3E%3Crect x='16.6' y='0' width='3.4' height='16' rx='1' fill='%23E4002B'/%3E%3C/svg%3E");
  --signal-watermark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='160' viewBox='0 0 220 160'%3E%3Cg fill='white'%3E%3Crect x='10' y='120' width='7' height='24' rx='2'/%3E%3Crect x='21' y='104' width='7' height='40' rx='2'/%3E%3Crect x='32' y='88' width='7' height='56' rx='2'/%3E%3Crect x='43' y='72' width='7' height='72' rx='2'/%3E%3Crect x='150' y='30' width='7' height='24' rx='2'/%3E%3Crect x='161' y='14' width='7' height='40' rx='2'/%3E%3Crect x='172' y='-2' width='7' height='56' rx='2'/%3E%3Crect x='183' y='-18' width='7' height='72' rx='2'/%3E%3C/g%3E%3C/svg%3E");
}

@media (max-width: 920px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: column;
    gap: 0;
    padding: 18px 18px 14px;
  }

  .brand-row.vertical {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .logo-pill.stacked {
    flex-direction: row;
    padding: 6px;
  }

  .logo-pill.stacked img {
    width: 64px;
    height: 30px;
  }

  .menu-toggle {
    display: block;
  }

  .sidebar-nav {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
  }

  .sidebar-nav.open {
    display: flex;
  }

  .sidebar-nav .nav-link {
    width: 100%;
    text-align: left;
  }

  .workspace {
    margin-left: 0;
    padding: 20px 16px 40px;
  }

  h1 { font-size: 24px; }

  .summary-grid,
  .form-grid,
  .product-picker,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .panel {
    padding: 20px 18px 22px;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 24px 20px;
    border-radius: 16px;
  }

  .logo-pill img {
    width: 72px;
    height: 34px;
  }

  .metric.dark strong,
  .metric strong {
    font-size: 21px;
  }

  .grand-total strong {
    font-size: 25px;
  }

  button,
  .secondary,
  .nav-link {
    min-height: 46px;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    font-size: 16px;
  }

  table {
    min-width: 600px;
  }
}

.report-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.report-summary-bar .actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 640px) {
  .report-summary-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .report-summary-bar .actions-group {
    justify-content: flex-start;
  }
}

.lang-switch {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.flag-icon {
  display: inline-block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.lang-option.active {
  background: var(--primary);
  color: #fff;
}

.lang-option:not(.active):hover {
  background: var(--soft);
  color: var(--ink);
}

.sidebar .lang-switch {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar .lang-option {
  color: #FBD9DC;
}

.sidebar .lang-option.active {
  background: #fff;
  color: var(--primary-dark);
}

.pwa-install-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--primary-dark), var(--primary-deep));
  color: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transform: translateY(140%);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.pwa-install-banner.visible {
  transform: translateY(0);
  opacity: 1;
}

.pwa-install-banner img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  background: #fff;
  object-fit: contain;
  padding: 3px;
}

.pwa-install-banner .pwa-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-banner .pwa-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 2px;
}

.pwa-install-banner .pwa-desc {
  font-size: 12px;
  color: #FBD9DC;
  margin: 0;
  line-height: 1.35;
}

.pwa-install-banner .pwa-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.pwa-install-banner button {
  min-height: 32px;
  padding: 6px 14px;
  font-size: 12px;
  white-space: nowrap;
}

.pwa-install-banner .pwa-install-btn {
  background: #fff;
  color: var(--primary-dark);
  font-weight: 800;
  border-radius: 8px;
}

.pwa-install-banner .pwa-later-btn {
  background: transparent;
  color: #FBD9DC;
  font-weight: 600;
  border-radius: 8px;
  padding: 4px 14px;
  min-height: auto;
}

@media (max-width: 480px) {
  .pwa-install-banner {
    left: 10px;
    right: 10px;
    bottom: 10px;
    flex-wrap: wrap;
    padding: 14px;
    row-gap: 10px;
  }

  .pwa-install-banner .pwa-text {
    flex-basis: calc(100% - 54px);
  }

  .pwa-install-banner .pwa-actions {
    flex-direction: row;
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  .pwa-install-banner .pwa-later-btn {
    order: -1;
    margin-right: auto;
  }
}

.pwa-splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.pwa-splash-screen img {
  width: 55%;
  max-width: 260px;
  height: auto;
}

.pwa-splash-hide {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
