:root {
  --bg: #fff7ed;
  --panel: #ffffff;
  --ink: #1f1b16;
  --muted: #74675a;
  --line: #ead9c5;
  --orange: #f97316;
  --orange-dark: #c2410c;
  --orange-soft: #ffedd5;
  --gold: #f8b331;
  --green: #0f9f6e;
  --red: #dc2626;
  --shadow: 0 18px 60px rgba(124, 45, 18, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(249, 115, 22, 0.12), rgba(255, 247, 237, 0.7) 38%, rgba(248, 179, 49, 0.14)),
    var(--bg);
}

body.is-locked .app-shell {
  display: none;
}

body:not(.is-locked) .login-screen {
  display: none;
}

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

button {
  cursor: pointer;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
}

.login-copy,
.login-message,
.db-status {
  margin: 0;
  color: var(--muted);
}

.login-message {
  min-height: 20px;
  color: var(--red);
  font-weight: 800;
}

.db-status {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffaf5;
  border: 1px solid var(--line);
  font-size: 13px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: #fff;
  background: linear-gradient(180deg, #9a3412, #c2410c 48%, #f97316);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

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

.brand-lockup span,
.doc-note small {
  color: rgba(255, 255, 255, 0.76);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #9a3412;
  background: #fff7ed;
  box-shadow: inset 0 -6px 0 rgba(249, 115, 22, 0.2);
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.icon-button,
.ghost-button,
.primary-button,
.danger-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.nav-item {
  width: 100%;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  justify-content: flex-start;
  padding: 0 12px;
}

.nav-item:hover,
.nav-item.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.nav-item svg,
.ghost-button svg,
.primary-button svg,
.danger-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.doc-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.doc-note span,
.doc-note strong,
.doc-note small {
  display: block;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

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

.env-pill,
.user-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 800;
  background: var(--orange-soft);
  color: var(--orange-dark);
}

.user-pill {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #fff;
  border: 1px solid var(--line);
}

.icon-button,
.ghost-button {
  color: var(--orange-dark);
  background: #fff;
  border: 1px solid var(--line);
}

.icon-button {
  width: 42px;
  padding: 0;
}

.ghost-button,
.primary-button,
.danger-button {
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.24);
}

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

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.metric,
.panel,
.totals-bar {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(234, 217, 197, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.metric {
  padding: 18px;
  border-radius: 8px;
}

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

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

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  min-width: 0;
}

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

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

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

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

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

.activity-list,
.client-list,
.line-editor {
  display: grid;
  gap: 12px;
}

.activity-item,
.client-item,
.line-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf5;
}

.activity-item strong,
.activity-item span,
.client-item strong,
.client-item span {
  display: block;
}

.activity-item span,
.client-item span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.invoice-layout,
.settings-layout {
  display: grid;
  gap: 18px;
}

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

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

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

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

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.12);
}

.line-item {
  display: grid;
  grid-template-columns: 1.4fr repeat(6, minmax(88px, 1fr)) 42px;
  gap: 10px;
  align-items: end;
}

.line-item .remove-line {
  width: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: var(--red);
  background: #fee2e2;
}

.totals-bar {
  position: sticky;
  bottom: 14px;
  z-index: 5;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  gap: 14px;
  align-items: center;
}

.totals-bar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.totals-bar strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
}

.response-panel {
  margin-top: 18px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #301409;
  background: #fffaf5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  max-height: 420px;
  overflow: auto;
}

.api-reference {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.api-reference code,
.secret-box,
.manual-endpoint {
  display: block;
  border-radius: 8px;
  padding: 12px;
  color: #7c2d12;
  background: var(--orange-soft);
  border: 1px solid #fed7aa;
  overflow-wrap: anywhere;
}

.secret-box {
  margin-top: 14px;
}

.manual {
  display: grid;
  gap: 12px;
}

.manual h3 {
  margin: 10px 0 0;
  font-size: 17px;
}

.manual p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.is-hidden {
  display: none;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 18px;
}

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

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

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

  .nav-item {
    justify-content: center;
  }

  .doc-note {
    display: none;
  }

  .content-grid,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-list,
  .content-grid,
  .metric-grid,
  .form-grid.two,
  .totals-bar {
    grid-template-columns: 1fr;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .line-item {
    grid-template-columns: 1fr;
  }

  .line-item .remove-line {
    width: 100%;
  }
}
