html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

:root {
  --ink: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --brand: #1f4f7a;
  --brand-strong: #163a59;
  --accent: #9b6a2f;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-strong);
}

.btn {
  border-radius: 6px;
  font-weight: 600;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.app-nav {
  min-height: 70px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.navbar-brand {
  color: var(--ink);
  letter-spacing: 0;
}

.navbar .nav-link {
  color: var(--muted);
  font-weight: 600;
}

.navbar .nav-link:hover {
  color: var(--ink);
}

.app-shell {
  flex: 1 0 auto;
  max-width: 1280px;
  padding: 32px 24px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.page-heading h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.page-heading .btn,
.button-row {
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.quick-card,
.form-surface,
.table-panel,
.detail-grid > div,
.invoice-preview,
.content-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(24, 33, 47, 0.06);
}

.quick-card {
  display: grid;
  gap: 14px;
  min-height: 180px;
  padding: 22px;
  color: var(--ink);
}

.quick-card span {
  color: var(--accent);
  font-weight: 800;
}

.quick-card strong {
  font-size: 1.15rem;
}

.quick-card small {
  color: var(--muted);
  line-height: 1.45;
}

.content-band {
  margin-top: 22px;
  padding: 24px;
}

.content-band h2,
.table-panel h2,
.detail-grid h2,
.line-editor h2,
.notes-box h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 800;
}

.form-surface {
  padding: 24px;
}

.form-label {
  color: #344054;
  font-weight: 700;
}

.form-control,
.form-select {
  min-height: 42px;
  border-color: #cdd5df;
  border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(31, 79, 122, 0.14);
}

.form-control.is-invalid,
.form-select.is-invalid,
.input-validation-error {
  border-color: #c92a2a;
  box-shadow: 0 0 0 0.18rem rgba(201, 42, 42, 0.14);
}

.form-actions,
.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.validation-alert {
  display: none;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #f0a9a9;
  border-radius: 8px;
  color: #9b1c1c;
  background: #fff1f1;
  font-weight: 700;
}

.validation-alert.validation-summary-errors {
  display: block;
}

.validation-alert ul {
  margin: 0;
  padding-left: 18px;
}

.table-panel {
  overflow: hidden;
  padding: 6px 18px 12px;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom-color: var(--line);
}

.table td {
  padding-top: 16px;
  padding-bottom: 16px;
  color: #2f3a4a;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 10px;
  border: 1px solid #bfd0df;
  border-radius: 999px;
  color: var(--brand-strong);
  background: #eef5fa;
  font-size: 0.82rem;
  font-weight: 700;
}

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

.detail-grid > div {
  padding: 22px;
}

.line-editor {
  margin-top: 28px;
}

.line-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.line-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(240px, 1.6fr) 168px 150px 128px 94px;
  gap: 10px;
  min-width: 1050px;
  align-items: start;
  padding: 8px 0;
}

.line-header {
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.line-validation {
  display: block;
  min-height: 18px;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}

.hour-field {
  position: relative;
}

.hour-field .line-hours {
  padding-right: 34px;
}

.hour-field-controls {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  display: grid;
  width: 28px;
  overflow: hidden;
  border-left: 1px solid #d7dee8;
  border-radius: 0 5px 5px 0;
}

.hour-field-controls button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  color: #43546a;
  background: #f3f6fa;
  font-size: 0.72rem;
  line-height: 1;
}

.hour-field-controls button:first-child {
  border-bottom: 1px solid #d7dee8;
}

.hour-field-controls button:hover {
  background: #e8eef6;
}

.line-total {
  align-self: start;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #dce3ec;
  border-radius: 6px;
  color: var(--brand-strong);
  background: #f8fafc;
  font-weight: 800;
  text-align: right;
}

.invoice-line .remove-line {
  align-self: start;
  min-height: 42px;
}

.live-total-panel {
  display: grid;
  gap: 8px;
  width: min(360px, 100%);
  margin-top: 18px;
  margin-left: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.live-total-panel div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.live-total-panel div:last-child {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 1.1rem;
}

.invoice-preview {
  padding: 34px;
}

.invoice-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.invoice-preview-head h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.invoice-preview-head p {
  margin-bottom: 4px;
}

.totals-box {
  width: min(360px, 100%);
  margin-left: auto;
  margin-top: 20px;
}

.totals-box div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.grand-total {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 1.25rem;
}

.notes-box {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.footer {
  flex-shrink: 0;
  width: 100%;
  line-height: 60px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

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

  .page-heading,
  .invoice-preview-head {
    flex-direction: column;
  }

  .text-end {
    text-align: left !important;
  }
}

@media (max-width: 640px) {
  .app-nav,
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .quick-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row .btn,
  .button-row form,
  .button-row button,
  .form-actions .btn {
    width: 100%;
  }
}
