:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #66736d;
  --line: #dce4df;
  --surface: #ffffff;
  --surface-soft: #f6f8f5;
  --accent: #166c57;
  --accent-strong: #0f5141;
  --warning: #bd6a16;
  --danger: #b42318;
  --paid: #1f7a3f;
  --shadow: 0 18px 45px rgba(23, 33, 28, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    Meiryo,
    sans-serif;
  background: #eef3ef;
  color: var(--ink);
}

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: 28px;
  padding: 28px;
  background: #14231d;
  color: #f8fbf8;
}

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

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

.brand-name,
.brand-note,
.plan-label,
.plan-copy,
.eyebrow,
.section-kicker {
  margin: 0;
}

.brand-name {
  font-weight: 800;
}

.brand-note {
  color: #a9b7af;
  font-size: 12px;
}

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

.nav-item {
  color: #dfe8e3;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 7px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
}

.plan-box {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.plan-label {
  color: #bfcac4;
  font-size: 13px;
}

.plan-price {
  margin: 8px 0;
  font-size: 30px;
  font-weight: 850;
}

.plan-copy {
  color: #d4ddd8;
  font-size: 13px;
  line-height: 1.7;
}

.main {
  min-width: 0;
  padding: 32px;
}

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

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

h1,
h2 {
  margin: 4px 0 0;
  line-height: 1.25;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
}

h2 {
  font-size: 20px;
}

.topbar-actions,
.message-actions,
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.filter-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 15px;
  font-weight: 750;
}

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

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

.ghost-button,
.filter-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.filter-button.active {
  background: #e0f1e7;
  border-color: #a7d7bf;
  color: var(--accent-strong);
}

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

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef5f0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

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

label {
  display: grid;
  gap: 7px;
  color: #3c4943;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd7d0;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 108, 87, 0.13);
}

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

.message-preview {
  min-height: 240px;
  white-space: pre-wrap;
  line-height: 1.75;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

.message-actions {
  margin-top: 14px;
}

.invoice-panel {
  overflow: hidden;
}

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

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

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

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

td {
  font-size: 14px;
}

tr[aria-selected="true"] {
  background: #f1f8f3;
}

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

.icon-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 850;
}

.status-unpaid {
  background: #fff1de;
  color: var(--warning);
}

.status-sent {
  background: #e8f0ff;
  color: #2855a3;
}

.status-paid {
  background: #e7f6eb;
  color: var(--paid);
}

.overdue {
  color: var(--danger);
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #14231d;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    padding: 20px;
  }

  .nav,
  .plan-box {
    display: none;
  }

  .metrics,
  .workspace {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .workspace,
  .invoice-form {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .message-actions,
  .filters {
    display: grid;
    grid-template-columns: 1fr;
  }
}
