:root {
  color-scheme: light;
  --ink: #16211f;
  --muted: #63706b;
  --line: #d9e1dc;
  --paper: #fbfcfb;
  --panel: #ffffff;
  --green: #06c755;
  --green-dark: #049342;
  --teal: #047b83;
  --coral: #ce5e46;
  --amber: #b7791f;
  --blue: #3867d6;
  --soft-green: #e8f8ef;
  --soft-teal: #e7f6f7;
  --soft-coral: #fff0ed;
  --shadow: 0 18px 45px rgba(38, 52, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f4f8f6 0%, #edf3ef 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.brand strong,
.brand span,
.sidebar-note span,
.metric span,
.status-line span {
  display: block;
}

.brand span,
.sidebar-note span,
.muted,
.table-note {
  color: var(--muted);
  font-size: 13px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8f6;
}

.mode-tab {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.mode-tab.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 5px 16px rgba(36, 52, 45, 0.12);
}

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

.nav-item {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: var(--ink);
  background: var(--soft-green);
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

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

.top-actions,
.row-actions,
.inline-actions,
.section-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.section-heading {
  justify-content: space-between;
  align-items: flex-start;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.metrics {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

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

.panel,
.metric,
.tenant-hero,
.rich-menu {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.auth-panel {
  max-width: 420px;
  margin: 8vh auto 0;
}

.metric {
  min-height: 96px;
  padding: 16px;
}

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

.metric:nth-child(3n + 1) {
  background: linear-gradient(180deg, #fff 0%, var(--soft-green) 100%);
}

.metric:nth-child(3n + 2) {
  background: linear-gradient(180deg, #fff 0%, var(--soft-teal) 100%);
}

.metric:nth-child(3n) {
  background: linear-gradient(180deg, #fff 0%, var(--soft-coral) 100%);
}

form {
  display: grid;
  gap: 12px;
}

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

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

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

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.15);
}

.primary,
.secondary,
.danger,
.tiny {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 750;
}

.button-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}

.invoice-focus {
  display: grid;
  gap: 16px;
}

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

.invoice-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-green);
}

.invoice-summary span {
  color: var(--muted);
  font-size: 12px;
}

.validation-result {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-summary.valid {
  border-color: #bde9cd;
  background: var(--soft-green);
}

.import-summary.invalid {
  border-color: #f0c6bd;
  background: var(--soft-coral);
}

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

.primary:hover {
  background: var(--green-dark);
}

.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.danger {
  color: #fff;
  background: var(--coral);
}

.tiny {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

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

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--teal);
  background: var(--soft-teal);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.warn {
  color: var(--amber);
  background: #fff6df;
}

.badge.ok {
  color: var(--green-dark);
  background: var(--soft-green);
}

.badge.bad {
  color: var(--coral);
  background: var(--soft-coral);
}

.toast {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #bde9cd;
  border-radius: 8px;
  color: #07542a;
  background: #effbf3;
}

.toast.show {
  display: block;
}

.tenant-hero {
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  padding: 22px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(4, 123, 131, 0.92), rgba(6, 199, 85, 0.86)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='320' viewBox='0 0 520 320'%3E%3Crect width='520' height='320' fill='%23eaf7ef'/%3E%3Cpath d='M44 260h432V84L260 24 44 84z' fill='%23ffffff' opacity='.8'/%3E%3Cpath d='M104 116h52v52h-52zm84 0h52v52h-52zm84 0h52v52h-52zm84 0h52v52h-52zM104 194h52v52h-52zm84 0h52v52h-52zm84 0h52v52h-52zm84 0h52v52h-52z' fill='%2306c755' opacity='.35'/%3E%3C/svg%3E");
  background-size: cover;
}

.tenant-hero h2 {
  font-size: 30px;
  margin-bottom: 8px;
}

.status-line {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
}

.rich-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.rich-menu button {
  min-height: 78px;
  border: 0;
  background: #fff;
  font-weight: 800;
}

.rich-menu button:hover {
  background: var(--soft-green);
}

.log-payload {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .metrics,
  .two,
  .three,
  .tenant-hero {
    grid-template-columns: 1fr;
  }
}

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

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

  h1 {
    font-size: 28px;
  }

  .form-grid,
  .invoice-summary,
  .rich-menu {
    grid-template-columns: 1fr;
  }

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