:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #65716d;
  --line: #dce2dc;
  --accent: #116b5f;
  --accent-2: #b8422d;
  --soft: #e8f2ee;
  --warn: #9b5c00;
  --danger: #b32727;
  --shadow: 0 16px 40px rgba(20, 31, 27, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

body.auth-locked {
  background: var(--bg);
}

body.auth-locked .app-shell {
  display: none;
}

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

:focus-visible {
  outline: 3px solid rgba(17, 107, 95, 0.28);
  outline-offset: 2px;
}

button,
.import-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.68rem 0.9rem;
  cursor: pointer;
  min-height: 42px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  padding: 0.45rem 0.6rem;
}

.storage-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.storage-badge.success {
  background: #dff5ed;
  color: #0b6b3f;
  border: 1px solid #a8dcc6;
}

.storage-badge.warn {
  background: #fff1d6;
  color: var(--warn);
  border: 1px solid #e9c779;
}

button:hover,
.import-label:hover {
  filter: brightness(0.94);
}

button:disabled,
.import-label:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: none;
}

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

.sidebar {
  background: #10231f;
  color: #fff;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #e6c35c;
  color: #10231f;
  font-weight: 900;
  font-size: 1.4rem;
}

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

.brand small {
  color: #b6c7c1;
}

.nav {
  display: grid;
  gap: 0.4rem;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  direction: ltr;
  border-color: transparent;
  background: transparent;
  color: #dce8e4;
}

.nav button.active,
.nav button:hover {
  background: #1c3b35;
  border-color: #2d554d;
  color: #fff;
}

.sidebar-tools {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
}

.workspace {
  min-width: 0;
  padding: 1.4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.user-switch {
  min-width: 220px;
}

.search {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0.7rem;
}

textarea {
  resize: vertical;
  min-height: 42px;
  height: 42px;
  overflow: auto;
  white-space: pre-wrap;
}

textarea:focus {
  min-height: 88px;
}

.import-label input {
  display: none;
}

.hero-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

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

.metric {
  padding: 1rem;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.8rem;
  line-height: 1.08;
}

.content {
  display: grid;
  gap: 1rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.panel {
  padding: 1rem;
}

.release-panel {
  border-color: #bfd9d0;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
}

.notice {
  background: #fff8df;
  border: 1px solid #ecd27a;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: #4a3900;
}

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

.panel-header,
.view-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.view-actions {
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  min-width: 180px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  background: #fbfcfa;
  position: sticky;
  top: 0;
}

tr:hover td {
  background: var(--soft);
}

.cell-details {
  max-width: 18rem;
}

.cell-details summary {
  cursor: pointer;
  color: var(--ink);
  list-style-position: inside;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-details p {
  margin: 0.45rem 0 0;
  max-height: 8rem;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--muted);
}

.row-action {
  background: transparent;
  color: var(--accent);
  border-color: var(--line);
  padding: 0.45rem 0.6rem;
  min-height: 34px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: var(--soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.tag.warn {
  background: #fff1d6;
  color: var(--warn);
}

.tag.success {
  background: #dff5ed;
  color: #0b6b3f;
}

.tag.danger {
  background: #ffe1df;
  color: var(--danger);
}

.tag.info {
  background: #e8eef7;
  color: #31587a;
}

.notes-history summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.notes-history article {
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  min-width: 220px;
}

.notes-history p {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
}

.quick-list {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  list-style: none;
  margin: 0;
}

.quick-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}

.quick-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.compact-assignment-select {
  min-width: min(24rem, 100%);
}

.compact-assignment-select select {
  min-width: 14rem;
}

.compact-details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  margin-top: 0.75rem;
  padding: 0.75rem;
}

.compact-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--accent);
}

.compact-details p {
  margin: 0.55rem 0 0;
  overflow-wrap: anywhere;
}

.datastore-actions {
  justify-content: flex-start;
  margin-top: 0.75rem;
}

dialog {
  width: min(780px, calc(100vw - 2rem));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(10, 20, 17, 0.45);
}

#loginHint:empty {
  display: none;
}

.dialog-card {
  padding: 1rem;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dialog-header {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.5rem;
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

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

.field {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.86rem;
}

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

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

.permission-editor,
.note-editor,
.audit-editor,
.attachment-editor {
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 0.8rem;
}

.compact-permissions details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.compact-permissions summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  cursor: pointer;
}

.compact-permissions .form-grid {
  padding: 0 0.75rem 0.75rem;
}

.compact-choice {
  min-width: 0;
}

.choice-details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.choice-details summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.choice-details select {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
}

.protected-cell {
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  background: #f8faf8;
}

.rbac-module-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 0;
}

.rbac-module-editor summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.rbac-editor-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0 0.75rem 0.75rem;
}

.rbac-action-set {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem;
  margin: 0;
}

.rbac-action-set.active {
  display: block;
}

.rbac-action-set legend {
  padding: 0 0.35rem;
  font-weight: 800;
  color: var(--accent);
}

.rbac-action-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  background: #fff;
  color: var(--ink);
}

.toggle-pill input {
  width: auto;
}

.attachment-history {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  margin-bottom: 0.7rem;
}

.attachment-history summary {
  padding: 0.75rem;
  cursor: pointer;
  font-weight: 800;
  color: var(--accent);
}

.attachment-list {
  display: grid;
  gap: 0.6rem;
  padding: 0 0.75rem 0.75rem;
}

.attachment-list article {
  display: grid;
  gap: 0.45rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}

.attachment-preview-inline[hidden] {
  display: none;
}

.attachment-preview-inline {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr);
  border-top: 1px solid var(--line);
  padding: 0.75rem;
  background: var(--panel);
  max-height: min(68vh, 680px);
  overflow: hidden;
}

.attachment-preview-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.6rem;
}

.attachment-preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.attachment-preview-body {
  width: 100%;
  height: min(54vh, 560px);
  min-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.attachment-preview-body[hidden] {
  display: none;
}

.attachment-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: 0;
  background: #fff;
}

.attachment-preview-frame[hidden] {
  display: none;
}

.attachment-preview-message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  margin: 0;
  padding: 1rem;
}

.attachment-upload-status {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  margin: 0;
  padding: 0.75rem;
}

.attachment-upload-status[data-tone="progress"] {
  color: var(--accent);
}

.attachment-upload-status[data-tone="ok"] {
  color: var(--accent);
}

.attachment-upload-status[data-tone="error"] {
  color: var(--danger);
}

.attachment-print-frame {
  position: fixed;
  width: 1px;
  height: 1px;
  right: 0;
  bottom: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.permissions-history {
  max-width: 18rem;
}

.permissions-history summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 800;
  white-space: nowrap;
}

.permissions-list {
  max-height: 12rem;
  overflow: auto;
  padding-top: 0.45rem;
}

.permissions-list p {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) auto;
  gap: 0.6rem;
  margin: 0;
  padding: 0.38rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.permissions-list p:last-child {
  border-bottom: 0;
}

.governance-center {
  grid-column: 1 / -1;
}

.governance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.governance-summary span,
.governance-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 0.75rem;
}

.governance-section summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--brand);
}

.governance-section + .governance-section {
  margin-top: 0.65rem;
}

.rbac-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.7rem;
  margin-top: 0.75rem;
  max-height: 28rem;
  overflow: auto;
}

.rbac-overview article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: #fff;
}

.rbac-overview h4 {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.diagnostic-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-top: 0.75rem;
}

.diagnostic-result {
  margin-top: 0.8rem;
}

.diagnostic-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.diagnostic-columns article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.75rem;
}

.diagnostic-columns h4 {
  margin-bottom: 0.55rem;
}

.diagnostic-list li {
  font-size: 0.84rem;
}

.quality-audit {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.quality-audit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.quality-audit-grid details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.75rem;
}

.quality-audit-grid summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--accent);
}

.permission-editor h3,
.note-editor h3,
.audit-editor h3,
.mini-form h3,
.custom-list h3 {
  margin-bottom: 0.55rem;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check-line input {
  width: auto;
}

.finance-form {
  margin-top: 0.8rem;
}

.finance-user {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  display: grid;
  gap: 0.65rem;
}

.finance-user h4 {
  margin: 0;
}

.generated-output {
  min-height: 44px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-top: 0.75rem;
  white-space: pre-wrap;
  color: var(--ink);
  background: #fbfcfa;
}

select[multiple] {
  min-height: 136px;
}

.config-panel {
  border-color: #b9d8cf;
  background: #fbfffd;
}

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

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

.tag-cloud {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.mini-form {
  display: grid;
  gap: 0.75rem;
}

.inline-form {
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 220px) auto;
  align-items: end;
  margin-top: 1rem;
}

.custom-list,
.user-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.user-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.45rem;
  align-items: center;
  width: 100%;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.access-grid label,
.currency-line {
  display: block;
}

.currency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

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

.dialog-actions {
  padding: 1rem 0 0;
  margin: 0;
}

.spacer {
  flex: 1;
}

.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.high-contrast {
  --bg: #000;
  --panel: #050505;
  --ink: #fff;
  --muted: #d6d6d6;
  --line: #767676;
  --accent: #ffd43b;
  --accent-2: #76e4ff;
  --soft: #1c1c1c;
  --shadow: none;
}

.high-contrast input,
.high-contrast select,
.high-contrast textarea,
.high-contrast th {
  background: #000;
  color: #fff;
}

.high-contrast .notice {
  background: #111;
  color: #fff;
}

.large-text {
  font-size: 118%;
}

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

  .sidebar {
    position: static;
  }

  .topbar,
  .dashboard-grid {
    display: grid;
  }

  .hero-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .config-grid,
  .pro-grid,
  .inline-form,
  .user-row,
  .rbac-editor-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 0.8rem;
  }

  .hero-band,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .topbar-actions > *,
  .topbar-actions button {
    width: 100%;
  }
}
