:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --panel: #101826;
  --panel-2: #162235;
  --text: #172033;
  --muted: #6a7485;
  --line: #dce5ee;
  --line-strong: #bdc9d6;
  --accent: #008b7a;
  --accent-2: #0f6dff;
  --amber: #d48900;
  --red: #d64045;
  --green: #157f4f;
  --cyan: #008ea8;
  --shadow: 0 18px 48px rgba(20, 34, 52, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 260px;
  --topbar: 74px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 139, 122, 0.14), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(15, 109, 255, 0.12), transparent 30%),
    var(--bg);
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-brand strong {
  display: block;
  font-size: 18px;
}

.login-brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.login-card p {
  margin: 10px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.license-card {
  width: min(540px, 100%);
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--red);
  background: #ffe7e8;
  font-weight: 800;
  font-size: 13px;
}

.device-box {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.device-box span,
.license-note {
  color: var(--muted);
  font-size: 12px;
}

.device-box strong {
  word-break: break-all;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  color: #e8eef7;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #00a98f, #0f6dff);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.brand strong {
  display: block;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #aab5c5;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 5px;
  padding: 18px 0;
}

.nav button {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  color: #b7c4d4;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 10px 10px;
  text-align: left;
  font-size: 14px;
}

.nav button:hover,
.nav button.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav .count {
  min-width: 20px;
  border-radius: 999px;
  padding: 2px 7px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-summary {
  margin-top: 8px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-summary span {
  display: block;
  color: #9daabe;
  font-size: 12px;
  margin-bottom: 6px;
}

.sidebar-summary strong {
  display: block;
  font-size: 21px;
  line-height: 1;
}

.sidebar-summary small {
  display: block;
  margin-top: 10px;
  color: #9edbd0;
  line-height: 1.4;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: var(--topbar);
  padding: 14px 24px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.page-title h1 {
  font-size: 22px;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.03em;
}

.page-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 900px;
}

.search {
  width: min(320px, 24vw);
  min-width: 210px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

.top-actions .select {
  width: 220px;
}

.role-select {
  min-width: 150px;
}

.user-pill {
  min-height: 42px;
  display: grid;
  justify-content: center;
  gap: 1px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}

.user-pill strong {
  font-size: 13px;
}

.sync-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.sync-pill.green {
  border-color: #bde8dc;
  color: var(--green);
  background: #eefaf6;
}

.sync-pill.amber {
  border-color: #f1d18b;
  color: #916000;
  background: #fff7e6;
}

.sync-pill.red {
  border-color: #f0b8bb;
  color: var(--red);
  background: #ffe7e8;
}

.sync-pill.gray {
  color: #5c6675;
  background: #f3f6f9;
}

.user-pill span {
  color: var(--muted);
  font-size: 12px;
}

.select,
.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 10px 11px;
  min-height: 40px;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #ffffff;
  white-space: nowrap;
}

.btn.secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.btn.warn {
  background: var(--amber);
}

.btn.danger {
  background: var(--red);
}

.btn.ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.content {
  padding: 24px;
  display: grid;
  gap: 20px;
}

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(20, 34, 52, 0.06);
}

.kpi .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(23px, 2.5vw, 32px);
  letter-spacing: -0.05em;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.delta {
  font-weight: 900;
  color: var(--green);
}

.delta.bad {
  color: var(--red);
}

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

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(20, 34, 52, 0.05);
  overflow: hidden;
}

.panel-header {
  min-height: 54px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

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

.panel-body {
  padding: 16px;
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-row,
.action-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.red {
  background: var(--red);
}

.status-dot.amber {
  background: var(--amber);
}

.status-dot.blue {
  background: var(--accent-2);
}

.status-dot.gray {
  background: #8b95a3;
}

.muted {
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f5f8fb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td.num,
th.num {
  text-align: right;
}

.row-title {
  font-weight: 850;
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #e7f5f1;
  color: var(--green);
}

.badge.red {
  background: #ffe7e8;
  color: var(--red);
}

.badge.amber {
  background: #fff3d8;
  color: #9a6500;
}

.badge.blue {
  background: #e7f0ff;
  color: var(--accent-2);
}

.badge.gray {
  background: #edf1f5;
  color: #5c6675;
}

.chart-bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8eef4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

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

.quick-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 13px;
  color: var(--text);
}

.quick-card strong {
  display: block;
  margin-bottom: 4px;
}

.quick-card span {
  color: var(--muted);
  font-size: 12px;
}

.pos-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(380px, 1.35fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.pos-form {
  grid-template-columns: 1fr 1fr;
}

.product-suggestions {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.product-suggestion {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
}

.product-suggestion:hover,
.product-suggestion.active {
  border-color: var(--accent);
  background: #edf7f4;
}

.product-suggestion span {
  color: var(--muted);
  font-size: 12px;
}

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

.price-hint {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #edf7f4;
  color: #24473f;
  border: 1px solid #c9e8df;
  font-size: 13px;
  line-height: 1.45;
}

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

.payment-box .summary-item {
  background: #f8fbfd;
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: -10px 0 14px rgba(238, 243, 247, 0.9);
}

.actions-head {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #f5f8fb;
  box-shadow: -10px 0 14px rgba(238, 243, 247, 0.9);
}

.table-actions .btn {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

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

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filters .select,
.filters .input {
  width: auto;
  min-width: 180px;
}

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

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

.field label,
.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.view-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.04em;
}

.view-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

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

.summary-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-soft);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.summary-item strong {
  font-size: 18px;
}

.service-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.hidden-file {
  display: none;
}

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

.license-advice div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.license-advice strong,
.license-advice span {
  display: block;
}

.license-advice span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(11, 18, 30, 0.48);
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
}

.modal-backdrop.open {
  display: flex;
}

.drawer {
  width: min(520px, 100%);
  min-height: 100vh;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
  overflow: auto;
}

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

.drawer-head h2 {
  margin: 0;
  font-size: 21px;
}

.drawer-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.drawer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: #101826;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

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

.mobile-menu {
  display: none;
}

.print-root {
  display: none;
}

.invoice-print {
  color: #111827;
  background: #ffffff;
  font-family: Arial, sans-serif;
}

.invoice-print.a4 {
  width: 210mm;
  min-height: 297mm;
  padding: 14mm;
}

.invoice-print.ticket {
  width: 80mm;
  padding: 4mm;
  font-size: 11px;
}

.invoice-print-head,
.invoice-print-info,
.invoice-print-totals {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.invoice-print-head {
  align-items: flex-start;
  border-bottom: 2px solid #111827;
  padding-bottom: 16px;
  margin-bottom: 18px;
}

.invoice-print h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.invoice-print p {
  margin: 3px 0;
}

.invoice-print-meta {
  text-align: right;
  display: grid;
  gap: 4px;
}

.invoice-print-meta strong {
  font-size: 24px;
}

.invoice-print-info {
  margin: 18px 0;
  padding: 12px;
  border: 1px solid #d1d5db;
}

.invoice-print-info span {
  display: block;
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}

.invoice-print-table {
  width: 100%;
  border-collapse: collapse;
}

.invoice-print-table th,
.invoice-print-table td {
  padding: 8px;
  border: 1px solid #d1d5db;
  white-space: normal;
  font-size: 12px;
}

.invoice-print-table th {
  background: #111827;
  color: #ffffff;
}

.invoice-print-table span {
  color: #6b7280;
}

.invoice-print-totals {
  margin-top: 18px;
  align-items: flex-start;
}

.totals-box {
  min-width: 260px;
  border: 1px solid #111827;
}

.totals-box p {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 9px 10px;
  border-bottom: 1px solid #d1d5db;
}

.totals-box p:last-child {
  border-bottom: 0;
}

.invoice-print-footer {
  margin-top: 26px;
  padding-top: 12px;
  border-top: 1px solid #d1d5db;
  text-align: center;
  color: #4b5563;
}

.invoice-print.ticket .invoice-print-head,
.invoice-print.ticket .invoice-print-info,
.invoice-print.ticket .invoice-print-totals {
  display: block;
}

.invoice-print.ticket .invoice-print-meta,
.invoice-print.ticket .invoice-print-footer {
  text-align: left;
}

.invoice-print.ticket .invoice-print-table th,
.invoice-print.ticket .invoice-print-table td {
  padding: 4px;
  font-size: 10px;
}

.invoice-print.ticket .totals-box {
  min-width: 0;
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .sidebar {
    padding: 16px 10px;
  }

  .brand {
    justify-content: center;
    padding: 4px 0 16px;
  }

  .brand div:not(.brand-mark),
  .nav .label,
  .nav .count,
  .sidebar-summary {
    display: none;
  }

  .nav button {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .kpi-grid,
  .summary-strip,
  .license-advice {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }

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

@media (max-width: 760px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0;
    top: 0;
    bottom: 0;
    width: 268px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

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

  .brand div:not(.brand-mark),
  .nav .label,
  .nav .count,
  .sidebar-summary {
    display: block;
  }

  .nav button {
    grid-template-columns: 24px 1fr auto;
    justify-items: stretch;
  }

  .topbar {
    align-items: flex-start;
    padding: 12px;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .search {
    width: 100%;
    min-width: 0;
  }

  .top-actions .select {
    width: 100%;
  }

  .role-select {
    width: 100%;
  }

  .content {
    padding: 14px;
  }

  .kpi-grid,
  .summary-strip,
  .quick-grid,
  .license-advice,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: auto;
  }

  .view-head,
  .topbar {
    display: grid;
  }

  .filters .select,
  .filters .input {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: auto;
    margin: 8mm;
  }

  body {
    background: #ffffff;
  }

  body * {
    visibility: hidden !important;
  }

  .print-root,
  .print-root * {
    visibility: visible !important;
  }

  .print-root {
    display: block !important;
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
  }

  .invoice-print {
    margin: 0 auto;
    box-shadow: none;
  }

  .invoice-print.ticket {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
