:root {
  --bg: #f6f4ee;
  --panel: #fffef9;
  --ink: #171717;
  --muted: #70706b;
  --line: #dedbd1;
  --green: #087a5b;
  --red: #b7422c;
  --amber: #a36f00;
  --blue: #265f91;
  --shadow: 0 14px 40px rgba(23, 23, 23, 0.08);
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", Aptos, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
}

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

.app {
  width: min(1280px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.app-header,
.command-bar,
.overview,
.workbench,
.ledger-head,
.queue-head,
.header-actions,
.mode-control,
.tabs {
  display: flex;
  align-items: center;
}

.app-header {
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
}

.brand {
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
  letter-spacing: 0;
  text-decoration: none;
}

.header-actions {
  gap: 8px;
}

.text-link,
.quiet-button,
.secondary-button,
.primary-button,
.file-button,
.mode-button,
.tabs button,
.row-mode,
.row-action {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.text-link,
.quiet-button,
.secondary-button,
.primary-button,
.file-button,
.mode-button,
.tabs button,
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  text-decoration: none;
  cursor: pointer;
}

.quiet-button {
  background: transparent;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary-button.is-live {
  border-color: var(--red);
  background: var(--red);
}

.secondary-button.is-live {
  border-color: var(--green);
  background: rgba(8, 122, 91, 0.12);
  color: var(--green);
}

.primary-button:disabled,
.secondary-button:disabled,
.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.file-button {
  position: relative;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.command-bar {
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 249, 0.84);
  box-shadow: var(--shadow);
  padding: 10px;
}

.mode-control {
  gap: 7px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

.mode-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.mode-button.is-active,
.tabs button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.status-line,
.legal-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}

.status-line {
  min-height: 20px;
  margin: 10px 2px 0;
}

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

.overview article,
.queue,
.ledger {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.overview article {
  min-width: 0;
  padding: 16px;
}

.overview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.overview strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1;
}

.workbench {
  align-items: stretch;
  gap: 12px;
  margin-top: 12px;
}

.queue {
  flex: 0 0 330px;
  min-width: 0;
  padding: 14px;
}

.queue-head {
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1;
}

#queueCount {
  display: inline-grid;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.queue-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.queue-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf5;
  padding: 11px;
}

.queue-item strong {
  display: block;
  font-size: 14px;
}

.queue-item span,
.empty-copy,
.empty-state span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.mini-button {
  min-height: 30px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.draft-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.draft-head strong {
  font-size: 15px;
}

.draft-panel textarea {
  width: 100%;
  min-height: 210px;
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf5;
  color: var(--ink);
  padding: 11px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  resize: vertical;
}

.ledger {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.ledger-head {
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.tabs {
  flex-wrap: wrap;
  gap: 7px;
}

.tabs button {
  min-height: 36px;
  font-size: 13px;
}

.empty-state {
  display: grid;
  min-height: 340px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 24px;
  text-align: center;
}

.empty-state strong {
  font-size: 22px;
}

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

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

th {
  background: #f1efe7;
  color: #4f4f4b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.client-mail {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-top: 2px;
}

.tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 950;
}

.tag.overdue {
  background: rgba(183, 66, 44, 0.12);
  color: var(--red);
}

.tag.soon {
  background: rgba(163, 111, 0, 0.14);
  color: var(--amber);
}

.tag.promise {
  background: rgba(38, 95, 145, 0.13);
  color: var(--blue);
}

.tag.dispute {
  background: rgba(23, 23, 23, 0.1);
  color: var(--ink);
}

.tag.ok {
  background: rgba(8, 122, 91, 0.12);
  color: var(--green);
}

.row-mode {
  width: 122px;
  padding: 0 8px;
}

.row-action {
  min-width: 92px;
  min-height: 36px;
  border-color: var(--green);
  color: var(--green);
  font-size: 13px;
  font-weight: 950;
}

.row-action.is-live {
  background: rgba(8, 122, 91, 0.12);
}

.action-cell {
  max-width: 260px;
}

.action-state {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  margin-top: 5px;
}

.legal-note {
  margin: 12px 2px 0;
}

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

  .workbench {
    flex-direction: column;
  }

  .queue {
    flex-basis: auto;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 16px, 1280px);
    padding-top: 12px;
  }

  .app-header,
  .header-actions,
  .mode-control {
    align-items: stretch;
    flex-direction: column;
  }

  .command-bar > *,
  .header-actions > *,
  .mode-control > button,
  .file-button {
    width: 100%;
  }

  .mode-control {
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 10px 0 0;
  }

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