:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #172033;
  --muted: #667085;
  --line: #e3e7ee;
  --accent: #159a70;
  --accent-2: #2563eb;
  --danger: #c2410c;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

[v-cloak] {
  display: none;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(21, 154, 112, 0.12), transparent 35%),
    linear-gradient(240deg, rgba(37, 99, 235, 0.10), transparent 35%),
    var(--bg);
}

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

.login-panel h1 {
  margin: 14px 0 4px;
  font-size: 30px;
  letter-spacing: 0;
}

.login-panel p {
  color: var(--muted);
  margin: 0 0 22px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  background: linear-gradient(135deg, #159a70, #2563eb);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

body.dark-body {
  color-scheme: dark;
  color: var(--ink);
  background: var(--bg);
  --bg: #0f141b;
  --panel: #18212c;
  --panel-2: #101923;
  --ink: #f8fafc;
  --muted: #c2cbd6;
  --line: #354153;
  --accent: #32c08b;
  --accent-2: #7cb1ff;
  --danger: #ff9b6a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

.dark-shell {
  color: var(--ink);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dark-shell .sidebar {
  background: #111a24;
  border-right-color: #3a4658;
}

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

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 13px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav button,
.ghost-btn,
.secondary-btn,
.primary-btn,
.link-btn,
.icon-btn {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  font-weight: 700;
}

.sidebar nav button {
  text-align: left;
  color: var(--muted);
  background: transparent;
  padding: 10px 12px;
}

.sidebar nav button.active,
.sidebar nav button:hover {
  color: var(--ink);
  background: var(--panel-2);
}

.dark-shell .sidebar nav button {
  color: #d2d9e3;
}

.dark-shell .sidebar nav button.active,
.dark-shell .sidebar nav button:hover {
  color: #ffffff;
  background: #263244;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

.topbar {
  margin-bottom: 22px;
}

.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 44px);
}

.topbar-actions,
.form-actions,
.actions-cell,
.upload-row,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.view-stack {
  display: grid;
  gap: 18px;
}

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

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

.metric-panel {
  padding: 18px;
  min-height: 116px;
  display: grid;
  align-content: space-between;
}

.metric-panel span {
  color: var(--muted);
  font-weight: 700;
}

.metric-panel strong {
  font-size: 30px;
  letter-spacing: 0;
}

.panel {
  padding: 18px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
}

.secondary-btn {
  background: rgba(37, 99, 235, 0.11);
  color: var(--accent-2);
  padding: 0 14px;
}

.secondary-btn.active,
.secondary-btn:hover {
  background: rgba(37, 99, 235, 0.18);
  color: #1d4ed8;
}

.dark-shell .secondary-btn {
  background: rgba(124, 177, 255, 0.17);
  color: #d7e7ff;
}

.dark-shell .secondary-btn.active,
.dark-shell .secondary-btn:hover {
  background: rgba(50, 192, 139, 0.20);
  color: #eafff6;
}

.ghost-btn {
  background: var(--panel-2);
  color: var(--ink);
  padding: 0 14px;
}

.dark-shell .ghost-btn {
  background: #263244;
  color: #ffffff;
}

.link-btn {
  background: transparent;
  color: var(--accent-2);
  min-height: 28px;
  padding: 0 2px;
}

.link-btn.danger {
  color: var(--danger);
}

.icon-btn {
  width: 32px;
  height: 32px;
  background: var(--panel-2);
  color: var(--danger);
  font-size: 22px;
  line-height: 1;
}

.full {
  width: 100%;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  outline: none;
}

body.dark-body input,
body.dark-body select,
body.dark-body textarea {
  background: #0f1722;
  border-color: #465467;
  color: #ffffff;
}

body.dark-body input::placeholder,
body.dark-body textarea::placeholder {
  color: #aab5c2;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 154, 112, 0.12);
}

.check-row,
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input,
.switch input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

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

.wide {
  grid-column: 1 / -1;
}

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

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

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

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

td span {
  color: var(--muted);
  font-size: 13px;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
  font-weight: 700;
}

.empty-cell,
.empty-text {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status.paid {
  background: rgba(21, 154, 112, 0.12);
  color: #10835f;
}

.status.unpaid,
.status.overdue {
  background: rgba(194, 65, 12, 0.12);
  color: #c2410c;
}

.status.partial,
.status.draft {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}

.status.sent,
.status.accepted {
  background: rgba(21, 154, 112, 0.12);
  color: #10835f;
}

.status.rejected {
  background: rgba(194, 65, 12, 0.12);
  color: #c2410c;
}

.dark-shell .status {
  background: #263244;
  color: #dce5ef;
}

.dark-shell .status.paid,
.dark-shell .status.sent,
.dark-shell .status.accepted {
  background: rgba(50, 192, 139, 0.20);
  color: #9af0cc;
}

.dark-shell .status.unpaid,
.dark-shell .status.overdue,
.dark-shell .status.rejected {
  background: rgba(255, 155, 106, 0.18);
  color: #ffc0a1;
}

.dark-shell .status.partial,
.dark-shell .status.draft {
  background: rgba(124, 177, 255, 0.18);
  color: #cfe2ff;
}

.chart {
  height: 240px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding-top: 18px;
}

.chart-col {
  display: grid;
  gap: 8px;
  align-items: end;
  height: 100%;
  width: clamp(42px, 8vw, 76px);
  text-align: center;
}

.chart-bar {
  min-height: 10px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2563eb, #159a70);
}

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

.toast,
.form-message {
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.toast {
  margin-bottom: 18px;
}

.success {
  background: rgba(21, 154, 112, 0.12);
  color: #10835f;
}

.error {
  background: rgba(194, 65, 12, 0.12);
  color: #c2410c;
}

body.dark-body .success {
  background: rgba(50, 192, 139, 0.20);
  color: #9af0cc;
}

body.dark-body .error {
  background: rgba(255, 155, 106, 0.18);
  color: #ffc0a1;
}

.filters {
  margin-bottom: 14px;
}

.filters input {
  max-width: 320px;
}

.filters select {
  max-width: 190px;
}

.invoice-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 18px;
}

.wide-panel {
  grid-column: 1 / -1;
}

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

.items-table {
  min-width: 1040px;
}

.items-table input {
  min-width: 92px;
}

.items-table td:first-child input,
.items-table td:nth-child(2) input {
  min-width: 180px;
}

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

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.summary-list span {
  color: var(--muted);
  font-weight: 700;
}

.summary-list .grand {
  border: 0;
  padding-top: 8px;
}

.summary-list .grand strong {
  color: var(--accent);
  font-size: 24px;
}

.pdv-note {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.editor-toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 12px;
  z-index: 5;
}

.editor-save-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.spacer {
  flex: 1;
}

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

.upload-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}

.dark-shell .metric-panel,
.dark-shell .panel,
.dark-shell .editor-toolbar,
.dark-shell .upload-card,
.dark-shell .asset-thumb {
  border-color: #3a4658;
}

.asset-thumb {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-weight: 900;
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.asset-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.asset-copy strong {
  color: var(--ink);
}

.asset-copy span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.upload-button {
  grid-column: 1 / -1;
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  cursor: pointer;
}

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

  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  }

  .sidebar nav button {
    text-align: center;
    padding: 10px 6px;
  }

  .content {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .form-actions {
    width: 100%;
  }

  .topbar-actions button,
  .form-actions button {
    flex: 1;
  }

  .form-grid,
  .invoice-grid,
  .quick-client,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .wide,
  .wide-panel {
    grid-column: auto;
  }
}

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

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

  .login-panel {
    padding: 22px;
  }

  .actions-cell {
    min-width: 220px;
  }
}
