:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #677281;
  --line: #d9e0e8;
  --paper: #ffffff;
  --soft: #f4f7fa;
  --nav: #162334;
  --nav-2: #223650;
  --blue: #2067b2;
  --green: #1d7f63;
  --amber: #b66d08;
  --red: #b23b3b;
  --cyan: #167f96;
  --shadow: 0 16px 36px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  background: var(--nav);
  color: #fff;
  padding: 24px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f6c344;
  color: #17202a;
  font-weight: 800;
}

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

.brand span {
  color: #b9c4d0;
  font-size: 13px;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe5ee;
  padding: 12px 14px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-2);
  color: #fff;
}

.side-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 16px;
  color: #d6dee8;
}

.side-panel p {
  margin: 8px 0 0;
  line-height: 1.5;
  font-size: 14px;
}

.main {
  padding: 28px;
  overflow: hidden;
}

.topbar,
.section-title,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

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

.toolbar,
.filters,
.dialog-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 11px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sync-status.online {
  background: #e7f5ef;
  color: var(--green);
}

.sync-status.saving {
  background: #fff1d8;
  color: var(--amber);
}

.sync-status.error {
  background: #ffe5e5;
  color: var(--red);
}

.primary-button,
.secondary-button,
.icon-button,
.ghost-button,
.segmented button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

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

.secondary-button {
  background: #eef5fb;
  border-color: #c8d9e8;
  font-weight: 700;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

.ghost-button {
  border: 0;
  background: transparent;
  font-size: 26px;
}

.filters {
  margin-bottom: 18px;
}

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

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.metric,
.panel,
.business-card,
.kanban-column,
.report {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(23, 32, 42, 0.03);
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 27px;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel,
.report {
  padding: 18px;
}

.bar-chart {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 155px 1fr 92px;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e9eef4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.request-list,
.packaging-list,
.expense-list,
.coop-list,
.special-list,
.brand-admin-list,
.audit-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.request-item,
.packaging-item,
.expense-item,
.coop-item,
.special-item,
.brand-admin-item,
.history-card,
.audit-item,
.kanban-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.request-item strong,
.packaging-item strong,
.expense-item strong,
.coop-item strong,
.special-item strong,
.brand-admin-item strong,
.history-card strong,
.audit-item strong,
.kanban-card strong {
  display: block;
  margin-bottom: 6px;
}

.packaging-item {
  display: grid;
  gap: 10px;
}

.packaging-item.overdue {
  border-color: #f0b8b8;
  background: #fffafa;
}

.packaging-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.date-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.date-controls label {
  font-size: 11px;
}

.date-controls input {
  min-height: 34px;
  padding: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef2f6;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.green {
  background: #e7f5ef;
  color: var(--green);
}

.pill.amber {
  background: #fff1d8;
  color: var(--amber);
}

.pill.red {
  background: #ffe5e5;
  color: var(--red);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 14px;
}

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

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

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

td.negative {
  color: var(--red);
  font-weight: 800;
}

.plan-board {
  padding-bottom: 10px;
}

.plan-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 680px;
}

.plan-table {
  min-width: 1860px;
  border-collapse: separate;
  border-spacing: 0;
}

.plan-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7fafc;
}

.plan-table th,
.plan-table td {
  border-right: 1px solid #edf1f5;
  vertical-align: top;
}

.plan-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.plan-row:hover td,
.plan-row:hover .sticky-col {
  background: #fbfdff;
}

.plan-table input,
.plan-table select {
  width: 100%;
  min-height: 34px;
  border-color: transparent;
  background: #f8fafc;
  padding: 6px 8px;
}

.plan-table input:focus,
.plan-table select:focus {
  border-color: var(--blue);
  background: #fff;
  outline: 0;
}

.status-select {
  min-width: 140px;
  font-weight: 800;
}

.status-select.green {
  background: #e7f5ef;
  color: var(--green);
}

.status-select.amber {
  background: #fff1d8;
  color: var(--amber);
}

.money-input {
  max-width: 120px;
}

.wide-input {
  min-width: 260px;
}

.date-cell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 250px;
}

.date-cell label {
  font-size: 11px;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

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

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.business-card {
  padding: 16px;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.user-card.inactive {
  opacity: 0.62;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.danger-button {
  border: 1px solid #f0b8b8;
  border-radius: 8px;
  min-height: 36px;
  background: #fff5f5;
  color: var(--red);
  padding: 0 12px;
  font-weight: 700;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.history-card {
  display: grid;
  gap: 10px;
}

.history-card ul {
  margin: 0;
  padding-left: 18px;
}

.brand-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.brand-row {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented button {
  border: 0;
  min-height: 34px;
  background: transparent;
}

.segmented button.active {
  background: var(--nav);
  color: #fff;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 14px;
  overflow-x: auto;
}

.kanban-column {
  padding: 12px;
  min-height: 420px;
  max-height: 720px;
  overflow: auto;
}

.kanban-column h3 {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.kanban-stack {
  display: grid;
  gap: 10px;
}

.donut-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-top: 18px;
}

.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0deg, var(--blue) var(--fmDeg), var(--green) var(--fmDeg), var(--green) 360deg);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: #fff;
}

.legend {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.report {
  display: grid;
  gap: 18px;
  line-height: 1.55;
}

.report h3 {
  margin-bottom: 4px;
}

.report ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(18, 28, 42, 0.42);
}

.dialog-card {
  padding: 20px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

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

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

.dialog-actions {
  justify-content: end;
  margin-top: 18px;
}

.form-note {
  color: var(--muted);
  line-height: 1.45;
}

.form-note.error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red);
  font-weight: 700;
}

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

  .sidebar {
    position: static;
  }

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

  .nav-item {
    text-align: center;
  }

  .metric-grid,
  .layout-two,
  .business-grid,
  .history-grid,
  .user-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .topbar,
  .section-title,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .metric-grid,
  .layout-two,
  .business-grid,
  .history-grid,
  .user-grid,
  .form-grid,
  .donut-row {
    grid-template-columns: 1fr;
  }

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