:root {
  --bg: #071019;
  --panel: rgba(13, 28, 43, 0.86);
  --panel-strong: #0d1f31;
  --line: rgba(126, 231, 255, 0.16);
  --text: #e9f7ff;
  --muted: #8da5b8;
  --cyan: #39d7ff;
  --green: #42f59b;
  --red: #ff5874;
  --amber: #ffd166;
  --blue: #5a8cff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --body-bg:
    radial-gradient(circle at 12% 12%, rgba(57, 215, 255, 0.12), transparent 30%),
    radial-gradient(circle at 90% 4%, rgba(66, 245, 155, 0.08), transparent 28%),
    linear-gradient(135deg, #06101a 0%, #081827 48%, #07111b 100%);
  --sidebar-bg: rgba(5, 15, 25, 0.94);
  --control-bg: rgba(2, 12, 22, 0.7);
  --label: #c6d8e6;
  --cell: #e8f6ff;
  --option-text: #0b1724;
  --toggle-bg: rgba(6, 16, 26, 0.9);
  --topbar-bg: rgba(13, 28, 43, 0.72);
  --grid-line: rgba(126, 231, 255, 0.055);
}

body.theme-light {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --line: rgba(31, 50, 74, 0.14);
  --text: #142033;
  --muted: #637083;
  --cyan: #2563eb;
  --green: #18a566;
  --red: #dc3545;
  --amber: #c98900;
  --blue: #2563eb;
  --shadow: 0 12px 34px rgba(20, 32, 51, 0.11);
  --body-bg:
    radial-gradient(circle at 8% 8%, rgba(37, 99, 235, 0.14), transparent 26%),
    radial-gradient(circle at 92% 6%, rgba(34, 211, 238, 0.16), transparent 28%),
    linear-gradient(135deg, #edf6ff 0%, #ffffff 44%, #effbff 100%);
  --sidebar-bg: rgba(255, 255, 255, 0.96);
  --control-bg: #ffffff;
  --label: #344256;
  --cell: #1d2a3d;
  --option-text: #142033;
  --toggle-bg: rgba(255, 255, 255, 0.96);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --grid-line: rgba(37, 99, 235, 0.06);
}

* { box-sizing: border-box; }
html {
  width: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--body-bg);
  background-size: 34px 34px, 34px 34px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-card,
.panel,
.metric-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar,
.topbar,
.panel,
.login-card {
  color: var(--text);
}

body.theme-light .login-card,
body.theme-light .panel,
body.theme-light .metric-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 250, 255, 0.94));
  border-color: rgba(37, 99, 235, 0.14);
}

.login-card {
  border-radius: 18px;
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand span,
.login-copy,
.muted,
.empty-state span {
  color: var(--muted);
}

.brand-mark {
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: #04131f;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 0 28px rgba(57, 215, 255, 0.32);
}

.brand-mark.has-image {
  background: #ffffff;
  padding: 5px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: 0;
}

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--label);
  font-size: 13px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(141, 165, 184, 0.24);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--control-bg);
  outline: none;
}

textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(57, 215, 255, 0.13);
}

.money-input {
  font-weight: 900;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

select option {
  color: var(--option-text);
}

.primary,
.ghost,
.danger,
.success,
.warning {
  min-height: 42px;
  border-radius: 10px;
  padding: 10px 14px;
  color: #06101a;
  font-weight: 800;
}

.primary { background: linear-gradient(135deg, var(--cyan), #80efff); }
.success { background: linear-gradient(135deg, var(--green), #b8ffd8); }
.warning { background: linear-gradient(135deg, var(--amber), #ffe6a1); }
.danger { background: linear-gradient(135deg, var(--red), #ff9dad); color: #fff; }
.ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.full { width: 100%; }

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
  text-decoration: none;
}

.alert {
  border: 1px solid rgba(255, 88, 116, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  color: #ffdbe1;
  background: rgba(255, 88, 116, 0.12);
}
.hidden { display: none !important; }

.demo-box {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.import-box {
  display: grid;
  gap: 12px;
}

.import-box textarea {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.import-result {
  border: 1px solid rgba(66, 245, 155, 0.28);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(66, 245, 155, 0.1);
  font-size: 13px;
  font-weight: 800;
}

.import-result.warning {
  border-color: rgba(255, 209, 102, 0.35);
  background: rgba(255, 209, 102, 0.12);
}

.import-result.danger {
  border-color: rgba(255, 88, 116, 0.35);
  background: rgba(255, 88, 116, 0.12);
}

.logo-upload-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.logo-preview {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  color: #04131f;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-size: 24px;
  font-weight: 900;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 274px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  backdrop-filter: blur(18px);
  box-shadow: 18px 0 44px rgba(0, 0, 0, 0.18);
}

.nav {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.nav-item {
  width: 100%;
  border-radius: 10px;
  padding: 12px 14px;
  color: #f8fbff;
  text-align: left;
  background: transparent;
}

body.theme-light .nav-item {
  color: #0b1220;
}

body.theme-light .nav-item.active,
body.theme-light .nav-item:hover {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
}

.nav-item.active,
.nav-item:hover {
  color: #03111d;
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.app-shell {
  min-height: 100vh;
  margin-left: 274px;
  padding: 22px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(57, 215, 255, 0.08), rgba(66, 245, 155, 0.04)),
    var(--topbar-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

body.theme-light .topbar {
  border: 1px solid rgba(37, 99, 235, 0.12);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(6, 182, 212, 0.08)),
    var(--topbar-bg);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.08);
}

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

.pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  color: #d9efff;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 800;
}

body.theme-light .pill {
  color: #0b1220;
  background: rgba(37, 99, 235, 0.06);
}

.status.paid { color: #092113; background: var(--green); }
.status.unpaid { color: #28080e; background: #ff8da0; }
.status.overdue { color: #2c1500; background: #ffb454; }
.status.draft { color: #2c2204; background: var(--amber); }

.view { display: none; }
.view.active {
  display: grid;
  gap: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  border-radius: 14px;
  padding: 16px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(57, 215, 255, 0.12), rgba(66, 245, 155, 0.08)),
    var(--panel);
  box-shadow: var(--shadow);
}

.dashboard-hero h2 {
  font-size: 28px;
}

.analytics-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(18, 24, 39, 0.96), rgba(36, 42, 62, 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.analytics-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.analytics-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  color: #06101a;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-weight: 900;
}

.analytics-hero h2 {
  font-size: 30px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.analytics-tabs {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px;
}

.analytics-tabs span {
  border-radius: 8px;
  padding: 9px 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #ef476f, #f45f86);
  font-size: 12px;
  font-weight: 900;
}

.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: -10px;
}

.analytics-kpi {
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  color: #071019;
  background: #ffffff;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.18);
  text-align: center;
}

.analytics-kpi span,
.analytics-kpi small {
  display: block;
  color: #354256;
  font-weight: 800;
}

.analytics-kpi strong {
  display: block;
  margin: 8px 0 4px;
  color: #06101a;
  font-size: 26px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.analytics-kpi.green strong { color: #168a52; }
.analytics-kpi.red strong { color: #d3425c; }
.analytics-kpi.cyan strong { color: #087b92; }

.dashboard-board {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(240px, 0.65fr) minmax(260px, 0.8fr);
  gap: 14px;
}

.chart-wide {
  grid-row: span 2;
}

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

.month-grid span {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #ef476f, #f45f86);
  font-size: 12px;
  font-weight: 900;
}

.month-grid span.active {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: #06101a;
}

.donut-wrap {
  display: grid;
  place-items: center;
  gap: 14px;
}

.donut {
  display: grid;
  place-items: center;
  align-content: center;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, var(--panel-strong) 0 45%, transparent 46%),
    conic-gradient(#ef476f 0 calc(var(--debt) * 1%), #2aa7b8 0 100%);
}

.donut strong {
  color: var(--text);
  font-size: 28px;
}

.donut span,
.donut-legend span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.donut-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.donut-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.donut-legend i {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.donut-legend .paid { background: #2aa7b8; }
.donut-legend .debt { background: #ef476f; }

.rank-list {
  display: grid;
  gap: 12px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(90px, 0.8fr) auto;
  align-items: center;
  gap: 10px;
}

.rank-row strong,
.rank-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.rank-row b {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.rank-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(141, 165, 184, 0.2);
}

.rank-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, #ef476f, #2aa7b8);
}

.compact-stats {
  margin-top: 2px;
}

.tech-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.tech-stat {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 92px;
  border-radius: 12px;
  padding: 16px;
  overflow: hidden;
  color: #ffffff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.tech-stat::after {
  content: "";
  position: absolute;
  inset: auto -26px -34px auto;
  width: 116px;
  height: 116px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.tech-stat.blue { background: linear-gradient(135deg, #2563eb, #38bdf8); }
.tech-stat.green { background: linear-gradient(135deg, #168a52, #42d392); }
.tech-stat.red { background: linear-gradient(135deg, #c43c4a, #fb7185); }

.tech-stat strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  word-break: break-word;
}

.tech-stat span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  opacity: 0.94;
}

.tech-icon {
  position: relative;
  width: 52px;
  height: 52px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
}

.tech-icon.users::before,
.tech-icon.collector::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px 999px 10px 10px;
}

.tech-icon.receipt::before {
  content: "";
  position: absolute;
  inset: 9px 11px;
  border-top: 3px solid rgba(255, 255, 255, 0.9);
  border-bottom: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 9px 0 rgba(255, 255, 255, 0.9);
}

.tech-icon.box::before,
.tech-icon.cube::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  transform: rotate(45deg);
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-panel {
  min-height: 320px;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 10px;
  border-radius: 999px;
}

.chart-legend .paid { background: rgba(37, 99, 235, 0.48); }
.chart-legend .unpaid { background: rgba(244, 114, 182, 0.62); }

.bar-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(24px, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 235px;
  margin-top: 18px;
  padding: 16px 12px 8px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background-image:
    linear-gradient(to top, var(--line) 1px, transparent 1px);
  background-size: 100% 20%;
}

.bar-group {
  display: grid;
  gap: 8px;
  align-self: stretch;
  align-items: end;
  text-align: center;
}

.bar-stack {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  height: 190px;
}

.bar {
  width: 11px;
  min-height: 0;
  border-radius: 8px 8px 0 0;
}

.bar.paid { background: linear-gradient(180deg, rgba(56, 189, 248, 0.9), rgba(37, 99, 235, 0.45)); }
.bar.unpaid { background: linear-gradient(180deg, rgba(251, 113, 133, 0.95), rgba(244, 114, 182, 0.5)); }

.bar-group small {
  color: var(--muted);
  font-size: 11px;
  transform: rotate(-34deg);
  transform-origin: center;
}

.content-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

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

.panel {
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
}

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

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

.center-actions {
  justify-content: center;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.check-line span {
  color: var(--text);
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

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

.report-filter-panel {
  position: sticky;
  top: 14px;
  z-index: 4;
  background:
    linear-gradient(135deg, rgba(57, 215, 255, 0.14), rgba(66, 245, 155, 0.08)),
    var(--panel);
}

.report-filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr)) auto auto;
  align-items: end;
  gap: 12px;
}

.print-title {
  display: none;
}

.print-report-sheet {
  display: none;
}

.invoice-create-panel {
  max-width: 980px;
  margin-inline: auto;
  width: 100%;
}

.invoice-detail-panel {
  max-width: 1120px;
  margin-inline: auto;
  width: 100%;
}

.invoice-detail-sheet {
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(5, 14, 28, 0.42);
  padding: 22px;
}

.invoice-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.invoice-detail-head h2 {
  margin: 4px 0 0;
  font-size: 26px;
}

.invoice-detail-number {
  text-align: right;
}

.invoice-detail-number span,
.invoice-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-detail-number strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  margin: 4px 0;
}

.invoice-detail-number small,
.invoice-detail-grid small {
  color: var(--muted);
  font-weight: 700;
}

.invoice-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.invoice-detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.invoice-detail-grid strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-top: 6px;
  line-height: 1.6;
}

.invoice-print-table {
  margin: 0 0 18px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.full-span .table-wrap table {
  min-width: 920px;
}

.wide-data-panel {
  overflow: hidden;
}

.wide-data-panel .panel-head {
  align-items: flex-start;
}

.wide-table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
}

.wide-data-table {
  table-layout: fixed;
}

.reseller-data-table {
  min-width: 1120px;
}

.distribution-data-table {
  min-width: 1080px;
}

.reseller-data-table th:nth-child(1),
.reseller-data-table td:nth-child(1) {
  width: 190px;
}

.reseller-data-table th:nth-child(2),
.reseller-data-table td:nth-child(2) {
  width: 190px;
}

.reseller-data-table th:nth-child(3),
.reseller-data-table td:nth-child(3) {
  width: 140px;
}

.reseller-data-table th:nth-child(4),
.reseller-data-table td:nth-child(4) {
  width: 140px;
}

.reseller-data-table th:nth-child(5),
.reseller-data-table td:nth-child(5) {
  width: 260px;
}

.reseller-data-table th:nth-child(6),
.reseller-data-table td:nth-child(6) {
  width: 300px;
}

.distribution-data-table th:nth-child(1),
.distribution-data-table td:nth-child(1) {
  width: 210px;
}

.distribution-data-table th:nth-child(2),
.distribution-data-table td:nth-child(2) {
  width: 135px;
}

.distribution-data-table th:nth-child(3),
.distribution-data-table td:nth-child(3) {
  width: 200px;
}

.distribution-data-table th:nth-child(4),
.distribution-data-table td:nth-child(4) {
  width: 150px;
}

.distribution-data-table th:nth-child(5),
.distribution-data-table td:nth-child(5) {
  width: 270px;
}

.distribution-data-table th:nth-child(6),
.distribution-data-table td:nth-child(6) {
  width: 185px;
}

.wide-data-table th,
.wide-data-table td {
  overflow-wrap: anywhere;
}

.wide-data-table .actions {
  min-width: 0;
}

.wide-data-table .actions button {
  min-height: 38px;
  padding-inline: 11px;
  white-space: normal;
}

.table-tools {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.table-tools label {
  max-width: 320px;
  width: min(320px, 100%);
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  flex-wrap: wrap;
}

.table-pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

tfoot th {
  color: var(--text);
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: var(--cell);
  font-size: 14px;
}

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

.dist-line {
  grid-template-columns: minmax(120px, 1fr) 130px;
  align-items: end;
}

.dist-line label:first-child {
  grid-column: 1 / -1;
}

.dist-line .dist-remove {
  width: 100%;
  min-height: 44px;
  white-space: normal;
}

.stock-edit-table .stock-ending {
  border-color: rgba(90, 140, 255, 0.8);
  background: rgba(90, 140, 255, 0.16);
  font-weight: 900;
}

body.theme-light .stock-edit-table .stock-ending {
  border-color: rgba(37, 99, 235, 0.82);
  background: rgba(37, 99, 235, 0.09);
  color: #0f2e72;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}

.mobile-menu-toggle,
.mobile-menu-backdrop {
  display: none;
}

@media (max-width: 1100px) {
  .metric-grid,
  .tech-stat-grid,
  .dashboard-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-detail-grid { grid-template-columns: 1fr; }
  .dashboard-board { grid-template-columns: 1fr 1fr; }
  .chart-wide { grid-column: 1 / -1; grid-row: auto; }
  .content-grid { grid-template-columns: 1fr; }
  .form-grid.three { grid-template-columns: 1fr; }
  .mini-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dist-line { grid-template-columns: minmax(120px, 1fr) 130px; }
  .dist-line label:first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  body.menu-open { overflow: hidden; }
  .mobile-menu-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 40;
    display: grid;
    gap: 5px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    padding: 11px;
    border: 1px solid var(--line);
    background: var(--toggle-bg);
  }
  .mobile-menu-toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--cyan);
  }
  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.62);
  }
  body.menu-open .mobile-menu-backdrop { display: block; }
  .sidebar {
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .app-shell {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    padding: 70px 8px 16px;
    overflow: hidden;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    padding: 14px;
  }
  .topbar h1 {
    font-size: 34px;
    line-height: 1.1;
    overflow-wrap: anywhere;
  }
  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .top-actions .ghost,
  .top-actions .pill {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .metric-grid,
  .tech-stat-grid,
  .analytics-kpi-row,
  .dashboard-board,
  .dashboard-charts,
  .mini-form,
  .dist-line,
  .inline-form {
    grid-template-columns: 1fr;
  }
  .analytics-hero {
    grid-template-columns: 1fr;
    width: 100%;
    padding: 16px;
  }
  .analytics-title {
    align-items: flex-start;
  }
  .analytics-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }
  .analytics-hero h2 {
    font-size: 25px;
    line-height: 1.15;
  }
  .analytics-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .analytics-tabs span {
    text-align: center;
    padding-inline: 8px;
  }
  .analytics-hero .primary {
    width: 100%;
  }
  .analytics-kpi-row {
    margin-top: 0;
  }
  .analytics-kpi strong {
    font-size: 23px;
  }
  .month-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .rank-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .rank-row strong,
  .rank-row span {
    white-space: normal;
  }
  .rank-row b {
    white-space: normal;
  }
  .dashboard-hero,
  .table-tools,
  .report-filter-form {
    align-items: stretch;
    flex-direction: column;
  }
  .dashboard-hero {
    width: 100%;
    min-width: 0;
    padding: 16px;
  }
  .dashboard-hero h2 {
    font-size: 30px;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }
  .dashboard-hero .primary {
    width: 100%;
    white-space: normal;
  }
  .invoice-detail-sheet {
    padding: 14px;
  }
  .invoice-detail-head {
    flex-direction: column;
  }
  .invoice-detail-number {
    text-align: left;
  }
  .panel,
  .metric-card,
  .tech-stat,
  .login-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .tech-stat {
    grid-template-columns: 50px minmax(0, 1fr);
    padding: 14px;
  }
  .tech-icon {
    width: 46px;
    height: 46px;
  }
  .tech-stat strong,
  .metric-card strong {
    font-size: 22px;
    overflow-wrap: anywhere;
  }
  .tech-stat span,
  .metric-card span {
    overflow-wrap: anywhere;
  }
  .content-grid {
    grid-template-columns: 1fr;
  }
  .report-filter-form {
    display: grid;
    grid-template-columns: 1fr;
  }
  .table-tools {
    display: grid;
    grid-template-columns: 1fr;
  }
  .wide-data-panel {
    width: calc(100% + 8px);
    margin-inline: -4px;
    padding: 14px 8px;
    border-radius: 16px;
  }
  .wide-data-panel .panel-head h2 {
    font-size: 25px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  .wide-data-panel .table-tools {
    gap: 10px;
    margin-bottom: 10px;
  }
  .wide-data-panel .table-pager {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }
  .wide-data-panel .table-pager span {
    order: -1;
    width: 100%;
  }
  .wide-data-panel .table-pager button {
    width: 100%;
  }
  .wide-table-wrap {
    margin-inline: -2px;
    border-radius: 10px;
    scrollbar-width: thin;
  }
  .wide-data-table {
    min-width: 980px;
  }
  .reseller-data-table th:nth-child(1),
  .reseller-data-table td:nth-child(1) {
    width: 170px;
  }
  .reseller-data-table th:nth-child(2),
  .reseller-data-table td:nth-child(2) {
    width: 170px;
  }
  .reseller-data-table th:nth-child(5),
  .reseller-data-table td:nth-child(5) {
    width: 220px;
  }
  .reseller-data-table th:nth-child(6),
  .reseller-data-table td:nth-child(6) {
    width: 250px;
  }
  .distribution-data-table th:nth-child(1),
  .distribution-data-table td:nth-child(1) {
    width: 190px;
  }
  .distribution-data-table th:nth-child(3),
  .distribution-data-table td:nth-child(3) {
    width: 180px;
  }
  .distribution-data-table th:nth-child(5),
  .distribution-data-table td:nth-child(5) {
    width: 240px;
  }
  .table-tools label {
    max-width: none;
    width: 100%;
  }
  .table-pager {
    justify-content: stretch;
  }
  .table-pager button {
    flex: 1;
  }
  .bar-chart {
    overflow-x: auto;
    grid-template-columns: repeat(12, 34px);
  }
  .login-card {
    padding: 22px;
  }
}

@media print {
  @page { margin: 12mm; }
  .sidebar, .topbar, .mobile-menu-toggle, .mobile-menu-backdrop, .no-print, .reports-screen, .print-title { display: none !important; }
  body { background: #fff; color: #111; }
  .app-shell { margin: 0; padding: 0; }
  .view { display: none !important; }
  .view.active { display: block !important; }
  .print-report-sheet {
    display: block !important;
    padding: 0;
    color: #111;
    font-family: Arial, sans-serif;
  }
  .print-meta-row {
    display: grid;
    grid-template-columns: 150px 16px 1fr;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 13px;
  }
  .print-report-section {
    margin: 0 0 22px;
    break-inside: auto;
  }
  .print-report-section h2 {
    text-align: center;
    margin: 0 0 28px;
    color: #111;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0;
  }
  .print-report-section + .print-report-section {
    break-before: page;
  }
  .print-report-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 12px;
  }
  .print-report-table th,
  .print-report-table td {
    border: 1px solid #111;
    color: #111;
    padding: 7px 8px;
    text-align: center;
    vertical-align: middle;
  }
  .print-report-table th {
    font-weight: 900;
  }
  .print-report-table tfoot th {
    font-weight: 900;
  }
  .printing-invoice .view { display: none !important; }
  .printing-invoice #invoicesView { display: block !important; }
  .printing-invoice .invoice-create-panel,
  .printing-invoice .invoice-list-panel {
    display: none !important;
  }
  .printing-invoice .invoice-detail-panel {
    display: block !important;
    padding: 0;
    border: 0;
  }
  .printing-invoice .invoice-detail-sheet {
    border: 0;
    border-radius: 0;
    background: #fff;
    padding: 0;
    color: #111;
    font-family: Arial, sans-serif;
  }
  .printing-invoice .invoice-detail-grid > div {
    border-color: #111;
    background: #fff;
  }
  .printing-invoice .invoice-detail-head {
    border-bottom-color: #111;
  }
  .printing-invoice .invoice-print-table table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 12px;
  }
  .printing-invoice .invoice-print-table th,
  .printing-invoice .invoice-print-table td {
    border: 1px solid #111;
    color: #111;
    padding: 7px 8px;
    text-align: center;
  }
  .printing-invoice .invoice-print-table tfoot th {
    font-weight: 900;
  }
  .panel, .metric-card { box-shadow: none; border-color: #ddd; background: #fff; color: #111; break-inside: avoid; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .metric-card { padding: 10px; }
  .metric-card strong { font-size: 18px; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; font-size: 11px; }
  tr.hidden { display: table-row !important; }
  td, th, h1, h2, h3, .muted { color: #111; }
}
