:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #0f62fe;
  --primary-dark: #0047c6;
  --danger: #c62828;
  --danger-soft: #fff1f1;
  --success: #1b7f43;
  --success-soft: #eefaf2;
  --warning: #a15c00;
  --warning-soft: #fff7e6;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: #364152;
  font-weight: 650;
}

label input,
label select,
label textarea {
  font-weight: 400;
}

code {
  background: #eef2ff;
  border-radius: 6px;
  padding: 2px 6px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px;
  background: #101828;
  color: #e5e7eb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #0f62fe, #7c3aed);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #aeb8c8;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 36px;
}

.nav a {
  padding: 12px 14px;
  border-radius: 12px;
  color: #d8dee9;
  text-decoration: none;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer small {
  color: #aeb8c8;
}

.sidebar-footer a {
  margin-top: 10px;
  color: #fff;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.card {
  margin-bottom: 20px;
  padding: 22px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 24px;
}

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

.metric-card strong {
  font-size: clamp(26px, 3vw, 38px);
}

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

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title h2 {
  margin: 0;
  font-size: 19px;
}

.section-title span {
  color: var(--muted);
}

.filter-grid,
.grid-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 14px;
  align-items: end;
}

.stack-form {
  display: grid;
  gap: 15px;
}

.stack-form h2 {
  margin: 10px 0 0;
  font-size: 17px;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button:hover {
  border-color: #cbd5e1;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

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

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

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

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

.right {
  text-align: right;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.status.approved {
  background: #ecfdf5;
  color: #047857;
}

.status.rejected,
.status.sage_error {
  background: var(--danger-soft);
  color: var(--danger);
}

.status.sent_to_sage {
  background: var(--success-soft);
  color: var(--success);
}

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

.status-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flash {
  margin-bottom: 16px;
  border-radius: 14px;
  padding: 13px 15px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 700;
}

.flash.success {
  background: var(--success-soft);
  color: var(--success);
}

.flash.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(15, 98, 254, 0.18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(124, 58, 237, 0.16), transparent 35%),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.install-card {
  width: min(760px, 100%);
}

.install-brand {
  margin-bottom: 24px;
  color: var(--text);
}

.install-brand .brand small {
  color: var(--muted);
}

.search-box {
  position: relative;
}

.search-results {
  position: absolute;
  z-index: 20;
  right: 0;
  left: 0;
  display: none;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-results.active {
  display: block;
}

.result-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.result-item:last-child {
  border-bottom: 0;
}

.result-item:hover {
  background: var(--panel-soft);
}

.result-item small {
  color: var(--muted);
}

.selected-value {
  margin: 10px 0 0;
}

.small-input {
  max-width: 120px;
  padding: 8px 10px;
}

.password-input {
  min-width: 180px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-label {
  display: inline-flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox-label input {
  width: auto;
}

.compact-search {
  display: flex;
  gap: 8px;
  min-width: min(420px, 100%);
}

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

.detail-grid div {
  border-radius: 16px;
  padding: 14px;
  background: var(--panel-soft);
}

.detail-grid span,
.detail-grid strong {
  display: block;
}

.detail-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.note-box {
  margin-top: 14px;
  border-radius: 16px;
  padding: 14px;
  background: var(--panel-soft);
}

.price-lower-row {
  background: var(--danger-soft);
}

.danger-text {
  color: var(--danger);
  font-weight: 800;
}

.code-box {
  overflow-wrap: anywhere;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  padding: 14px;
  background: #eff6ff;
  color: #1e3a8a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metric-grid,
  .two-column,
  .filter-grid,
  .grid-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .section-title,
  .form-actions,
  .inline-form,
  .compact-search {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }
}

