:root {
  --ink: #17211f;
  --muted: #61706c;
  --paper: #f4f6f3;
  --surface: #ffffff;
  --line: #dfe6e2;
  --brand: #153d35;
  --brand-2: #28695b;
  --accent: #d66b33;
  --danger: #9c2f2f;
  --warning-bg: #fff4d4;
  --shadow: 0 12px 34px rgb(21 61 53 / 9%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

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

a:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: white;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
}

.brand:hover {
  text-decoration: none;
}

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

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

.brand-mark.large {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  border-radius: 18px;
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace-chip {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  color: var(--brand);
  background: #e8f1ee;
  font-weight: 650;
}

.app-frame {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100vh - 112px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.25rem 0.8rem;
  background: var(--brand);
}

.sidebar a {
  padding: 0.68rem 0.8rem;
  border-radius: 8px;
  color: #dfece8;
}

.sidebar a:hover,
.sidebar a.active {
  color: white;
  background: rgb(255 255 255 / 10%);
  text-decoration: none;
}

.main-content {
  width: 100%;
  max-width: 1500px;
  padding: 2rem;
}

.signed-out-content {
  display: grid;
  min-height: calc(100vh - 46px);
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 15% 10%, rgb(214 107 51 / 16%), transparent 28rem),
    radial-gradient(circle at 90% 80%, rgb(40 105 91 / 18%), transparent 30rem),
    var(--paper);
}

.login-card {
  width: min(100%, 440px);
  padding: 2.5rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin-bottom: 0.3rem;
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.65rem, 3vw, 2.3rem);
  letter-spacing: -0.025em;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  text-decoration: none;
}

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

.button.secondary {
  color: var(--brand);
  background: #e8f1ee;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.button.full {
  width: 100%;
  margin: 1rem 0;
}

.fine-print {
  color: var(--muted);
  font-size: 0.82rem;
}

.footer {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
}

.message-stack {
  margin-bottom: 1rem;
}

.message {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  background: #e8f1ee;
}

.message-error {
  color: var(--danger);
  background: #faeaea;
}

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

.page-heading,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat-card,
.panel {
  padding: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 14px rgb(21 61 53 / 4%);
}

.stat-card {
  display: flex;
  min-height: 145px;
  flex-direction: column;
  align-items: flex-start;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
}

.stat-card strong {
  margin: 0.4rem 0 auto;
  font-size: 2rem;
}

.stat-card a {
  margin-top: 0.65rem;
  font-size: 0.87rem;
  font-weight: 700;
}

.stat-card.warning {
  border-top: 4px solid #c4901f;
}

.stat-card.danger {
  border-top: 4px solid var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.panel.wide {
  grid-row: span 2;
}

.empty-state {
  margin-top: 1rem;
  padding: 2rem;
  text-align: center;
  background: var(--paper);
  border-radius: 10px;
}

.task-group {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.task-group.nested {
  padding-left: 1rem;
  color: var(--muted);
}

.form-card,
.table-card {
  margin-top: 1.4rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field.span-2 {
  grid-column: span 2;
}

.field label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: white;
  border: 1px solid #b9c5c1;
  border-radius: 7px;
  font: inherit;
}

.field input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
}

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

.field-error,
.form-errors {
  color: var(--danger);
  font-size: 0.85rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

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

.data-table th,
.data-table td {
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.numeric {
  text-align: right !important;
}

.danger-row {
  background: #fff1f1;
}

.danger-text {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 750;
}

.text-button {
  padding: 0;
  color: var(--danger);
  background: none;
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}

.action-card {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.2rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 14px rgb(21 61 53 / 4%);
}

.action-card:hover {
  border-color: var(--brand-2);
  text-decoration: none;
}

.action-card span {
  color: var(--muted);
}

.data-table th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  padding: 0.28rem 0.48rem;
  border-radius: 999px;
  color: var(--brand);
  background: #e8f1ee;
  font-size: 0.76rem;
  font-weight: 750;
}

.muted-badge {
  color: var(--muted);
  background: #ecefed;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}

.line-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr auto;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  padding: 0.8rem;
  background: var(--paper);
  border-radius: 9px;
}

.order-line-form,
.cost-line-form {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
  padding: 0.8rem;
  background: var(--paper);
  border-radius: 9px;
}

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

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.55rem;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-weight: 650;
}

.receipt-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.65rem;
  padding: 0.8rem;
  background: var(--paper);
  border-radius: 9px;
}

.callout-ui {
  padding: 0.85rem 1rem;
  background: var(--warning-bg);
  border-left: 4px solid #c4901f;
  border-radius: 6px;
}

.task-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}

.nested-task-panel {
  margin-left: 1.25rem;
  border-left: 4px solid var(--line);
}

.task-item,
.notification-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.task-item p,
.notification-item p {
  margin: 0.25rem 0;
}

.completed-task,
.notification-item.read {
  color: var(--muted);
  opacity: 0.75;
}

.completed-task strong {
  text-decoration: line-through;
}

.success-text {
  color: var(--brand-2);
}

.recommendation-card {
  margin-bottom: 1rem;
}

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

  .sidebar {
    position: sticky;
    top: 72px;
    z-index: 10;
    flex-direction: row;
    overflow-x: auto;
    padding: 0.55rem;
  }

  .sidebar a {
    white-space: nowrap;
  }

  .main-content {
    padding: 1.15rem;
  }

  .workspace-chip,
  .notification-link {
    display: none;
  }

  .stat-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .card-grid,
  .line-form,
  .action-grid,
  .order-line-form,
  .cost-line-form,
  .detail-grid,
  .receipt-row,
  .task-columns {
    grid-template-columns: 1fr;
  }

  .nested-task-panel {
    margin-left: 0;
  }

  .field.span-2 {
    grid-column: auto;
  }

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

@media (min-width: 851px) and (max-width: 1200px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.offline-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.65rem 1rem;
  background: #202020;
  color: #fff;
  text-align: center;
  font-weight: 700;
}

body.offline .offline-banner {
  display: block;
}

body.offline button[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
