:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #6b6f76;
  --line: #ded7cf;
  --panel: #ffffff;
  --soft: #fff7eb;
  --brand-black: #050505;
  --brand-orange: #f36f21;
  --brand-orange-dark: #d95612;
  --brand-amber: #f6a51a;
  --brand-yellow: #ffc20f;
  --brand-gray: #6d6f71;
  --green: #24895a;
  --red: #bd3b3b;
  --blue: #53616c;
  --shadow: 0 14px 34px rgba(35, 24, 12, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 194, 15, 0.16), rgba(255, 255, 255, 0) 240px),
    #f4f1ed;
  color: var(--ink);
  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 {
  border: 0;
  border-radius: 7px;
  background: var(--brand-orange);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--brand-orange-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-orange);
  box-shadow: 0 0 0 3px rgba(243, 111, 33, 0.16);
  outline: none;
}

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

label {
  display: block;
  color: #465365;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

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

h1 {
  font-size: 28px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 17px;
  margin-bottom: 12px;
}

.login-screen {
  align-items: center;
  background:
    radial-gradient(circle at 70% 15%, rgba(255, 194, 15, 0.24), transparent 28%),
    linear-gradient(135deg, #050505 0%, #171717 60%, #3a332b 100%);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 194, 15, 0.28);
  border-radius: 8px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 16px;
  max-width: 430px;
  padding: 26px;
  width: 100%;
}

.login-card img {
  background: #050505;
  border-radius: 8px;
  display: block;
  max-width: 260px;
  padding: 12px;
  width: 100%;
}

.login-help {
  color: var(--muted);
  font-size: 12px;
}

.topbar {
  align-items: center;
  background:
    radial-gradient(circle at 78% -20%, rgba(255, 194, 15, 0.32), transparent 26%),
    linear-gradient(135deg, #050505 0%, #171717 62%, #3a332b 100%);
  border-bottom: 4px solid var(--brand-orange);
  color: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 108px;
  padding: 18px 28px;
}

.topbar .eyebrow {
  color: var(--brand-yellow);
}

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

.brand-logo {
  display: block;
  height: 66px;
  max-width: 246px;
  object-fit: contain;
}

.session-panel {
  align-items: end;
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(220px, 1fr) auto;
  min-width: 330px;
}

.session-panel label {
  color: #c9d5dd;
  grid-column: 1;
}

.session-panel select {
  border-color: rgba(255, 255, 255, 0.2);
  grid-column: 1;
}

.session-user {
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  grid-column: 1 / -1;
  text-align: right;
}

.session-panel button {
  grid-row: 2;
  min-height: 40px;
}

.eyebrow {
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px;
}

.sidebar-brand {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding: 0 0 16px;
}

.sidebar-brand img {
  display: block;
  height: auto;
  max-width: 100%;
}

.sidebar nav {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 18px;
}

.nav-button {
  background: transparent;
  color: #3f4d5f;
  justify-content: flex-start;
  text-align: left;
}

.nav-button.active {
  background: #fff0d4;
  color: #7a3307;
}

.nav-button:hover {
  background: #fff6e6;
  color: #7a3307;
}

.content {
  min-width: 0;
  padding: 22px;
}

.filters,
.form-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  margin-bottom: 20px;
  padding: 16px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

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

.section-head > select {
  max-width: 280px;
}

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

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-orange);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 132px;
  padding: 16px;
}

.metric-card.money {
  border-left-color: var(--brand-yellow);
}

.metric-card.warning {
  border-left-color: var(--brand-amber);
}

.metric-card.risk {
  border-left-color: var(--red);
}

.metric-card .label {
  color: #536273;
  font-size: 13px;
  font-weight: 800;
}

.metric-card .value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.15;
  margin: 12px 0 8px;
  overflow-wrap: anywhere;
}

.metric-card .meta {
  color: var(--muted);
  font-size: 12px;
}

.split-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
}

.control-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
}

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

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

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

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

th {
  background: #fff8eb;
  color: #5b4331;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  font-size: 13px;
}

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

.pill {
  background: #fff1d6;
  border: 1px solid #ffd079;
  border-radius: 999px;
  color: #7a3307;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  min-height: 28px;
  padding: 5px 10px;
}

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

.status-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  padding: 14px;
}

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

.compact-form {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

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

.check-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin: 22px 0 0;
}

.permission-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.permission-grid .check-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin: 0;
  min-height: 42px;
  padding: 10px;
}

.check-row input {
  min-height: 18px;
  width: 18px;
}

.form-actions,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.export-actions {
  margin-bottom: 16px;
}

.ghost-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ghost-button:hover {
  background: #fff7eb;
  color: var(--brand-orange-dark);
}

.secondary-button {
  background: var(--brand-gray);
}

.secondary-button:hover {
  background: #55585a;
}

.danger-button {
  background: var(--red);
}

.tiny-button {
  min-height: 32px;
  padding: 0 10px;
}

.toast {
  background: var(--brand-black);
  border-bottom: 3px solid var(--brand-orange);
  border-radius: 8px;
  bottom: 18px;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty {
  color: var(--muted);
  padding: 18px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .filters,
  .metric-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .control-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .session-panel {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .session-user {
    text-align: left;
  }

  .session-panel button {
    grid-row: auto;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .brand-logo {
    height: 54px;
    max-width: 220px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }

  .content {
    padding: 16px;
  }

  .filters,
  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

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