:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #68747d;
  --line: #dde4ea;
  --brand: #0b1116;
  --accent: #05a6b8;
  --accent-strong: #007c91;
  --warning: #f3b61f;
  --danger: #c84630;
  --ok: #208a61;
  --shadow: 0 14px 40px rgba(17, 31, 41, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(5, 166, 184, 0.14), transparent 38%),
    linear-gradient(300deg, rgba(243, 182, 31, 0.18), transparent 34%),
    var(--bg);
}

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

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

.brand-lockup strong {
  display: block;
  letter-spacing: 0;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--brand);
  border-radius: 8px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(5, 166, 184, 0.14);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  color: white;
  background: #11181f;
}

.sidebar .brand-lockup small {
  color: #9fb2bf;
}

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

.nav-list button,
.ghost-button {
  min-height: 40px;
  padding: 10px 12px;
  text-align: left;
  color: #dbe6ec;
  background: transparent;
  border-radius: 7px;
}

.nav-list button:hover,
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-list button.active {
  color: #081116;
  background: #f3b61f;
}

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

.sidebar-footer label {
  color: #b8c7d0;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  background: rgba(245, 247, 249, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
}

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

.content {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 14px;
  padding: 20px 28px 40px;
}

.user-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  border-color: transparent;
  background: #e8f6f2;
  color: var(--ok);
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.small-button {
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-button {
  color: white;
  background: var(--accent-strong);
}

.primary-button:hover {
  background: #006c7e;
}

.secondary-button {
  color: var(--ink);
  background: #eaf0f3;
}

.secondary-button:hover {
  background: #dce7ec;
}

.danger-button {
  color: white;
  background: var(--danger);
}

.small-button {
  min-height: 26px;
  padding: 4px 8px;
  color: var(--ink);
  background: #eef3f6;
  font-size: 12px;
}

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

.danger-small:hover {
  background: #ab3827;
}

.grid {
  display: grid;
  align-items: start;
  gap: 14px;
}

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

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

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

.panel,
.metric,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(17, 31, 41, 0.02);
}

.panel {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 14px;
  padding: 14px;
}

.metric {
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

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

.table-wrap {
  overflow: auto;
}

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

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

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

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 10px 12px;
}

.form-grid .wide {
  grid-column: span 2;
}

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

.doc-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.line-items {
  display: grid;
  gap: 10px;
}

.line-item {
  display: grid;
  grid-template-columns: 48px minmax(180px, 0.9fr) minmax(260px, 1.2fr) 78px 72px 92px 82px 34px;
  gap: 8px 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.line-item label {
  min-width: 0;
}

.line-item textarea {
  min-height: 96px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.line-item .description-field {
  grid-column: 1 / -1;
}

.line-item .line-delete {
  width: 34px;
  min-height: 32px;
  padding: 0;
  align-self: end;
}

.totals {
  justify-self: end;
  min-width: 280px;
  display: grid;
  gap: 7px;
  padding: 12px;
  background: #f8fafb;
  border-radius: 8px;
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.totals strong {
  font-size: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 14px;
  color: #fff;
  background: #11181f;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

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

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

  .doc-layout,
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

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

  .form-grid .wide,
  .form-grid .full {
    grid-column: auto;
  }

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