:root {
  --bg: #07111d;
  --bg-soft: #0b1523;
  --panel: rgba(10, 19, 31, 0.9);
  --panel-2: rgba(13, 24, 39, 0.94);
  --line: rgba(176, 197, 225, 0.12);
  --line-strong: rgba(176, 197, 225, 0.22);
  --text: #eef3fa;
  --muted: #8ea0ba;
  --accent: #9fc0ff;
  --accent-2: #7dd8c4;
  --danger: #ff8f90;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  --btn-on-accent: #07111d;
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-2: #ffffff;
  --line: rgba(60, 67, 90, 0.10);
  --line-strong: rgba(60, 67, 90, 0.22);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0a84ff;
  --accent-2: #30b27a;
  --danger: #ff3b30;
  --shadow: 0 10px 28px rgba(60, 67, 90, 0.10);
  --btn-on-accent: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

.bi {
  line-height: 1;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(159, 192, 255, 0.13), transparent 28rem),
    linear-gradient(180deg, #06101a 0%, #08111b 100%);
}

.layout {
  width: min(1160px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.7rem 0 1.2rem;
}

.layout.narrow {
  width: min(520px, calc(100% - 1rem));
}

.hero {
  margin-bottom: 0.55rem;
}

.hero-head,
.metric-card,
.summary-card,
.card,
.fold,
.tabbar {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-head {
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
}

.hero-copy {
  min-width: 0;
}

.eyebrow,
.metric-label,
.summary-label,
.section-kicker,
.code-label {
  margin: 0 0 0.32rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  color: var(--accent-2);
}

.metric-label,
.summary-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.06;
}

h1 {
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  margin-bottom: 0.4rem;
  max-width: 13ch;
}

h2 {
  font-size: 0.98rem;
}

h2 span {
  display: inline-block;
}

h2 .bi {
  margin-right: 0.45rem;
  color: var(--accent);
  font-size: 0.95em;
}

.lede,
.compact-text,
.section-note,
.summary-detail,
.meta-inline {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.hero-actions,
.quick-actions,
.chip-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.hero-actions {
  justify-content: flex-end;
  flex-shrink: 0;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.metric-card,
.summary-card {
  border-radius: 11px;
  padding: 0.68rem 0.78rem;
}

.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.metric-value,
.summary-value {
  font-size: 1.04rem;
  font-weight: 700;
  white-space: nowrap;
}

.metric-detail {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.meter {
  height: 5px;
  margin-top: 0.52rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tabbar-shell {
  position: sticky;
  top: 0.6rem;
  z-index: 20;
  margin-bottom: 0.55rem;
}

.tabbar {
  display: inline-flex;
  gap: 0.28rem;
  padding: 0.24rem;
  border-radius: 11px;
  width: 100%;
  backdrop-filter: blur(14px);
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--muted);
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font-weight: 700;
}

.tab.is-active {
  color: var(--btn-on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.tab .bi {
  font-size: 0.92rem;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: grid;
  gap: 0.55rem;
}

.dashboard-grid,
.inventory-grid,
.service-grid {
  display: grid;
  gap: 0.55rem;
}

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

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

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

.attention-card {
  background: linear-gradient(180deg, rgba(14, 24, 39, 0.96), rgba(10, 18, 30, 0.92));
}

.attention-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
}

.attention-item {
  display: grid;
  gap: 0.28rem;
  padding: 0.72rem 0.78rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(176, 197, 225, 0.08);
}

.attention-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.attention-head strong {
  font-size: 0.9rem;
}

.attention-item p,
.attention-source,
.attention-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.attention-empty {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.72rem 0;
}

.attention-empty .bi {
  font-size: 1.1rem;
  color: var(--accent-2);
  margin-top: 0.1rem;
}

.attention-empty strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.92rem;
}

.summary-card {
  min-height: 106px;
  display: grid;
  align-content: start;
  gap: 0.18rem;
}

.card,
.fold {
  border-radius: 12px;
}

.card {
  padding: 0.85rem 0.95rem;
}

.card-soft {
  background: linear-gradient(180deg, rgba(12, 22, 35, 0.82), rgba(9, 17, 28, 0.9));
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.75rem;
}

.fold {
  overflow: hidden;
}

.fold summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  cursor: pointer;
  padding: 0.82rem 0.95rem;
}

.fold summary::-webkit-details-marker {
  display: none;
}

.fold-meta {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.fold-body {
  border-top: 1px solid rgba(176, 197, 225, 0.08);
  padding: 0 0.95rem 0.9rem;
}

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}

.form.single {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 0.34rem;
  font-size: 0.81rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  border-radius: 9px;
}

input,
select {
  padding: 0.68rem 0.75rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

input[readonly] {
  color: var(--accent-2);
}

button,
.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 0;
  padding: 0.68rem 0.88rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--btn-on-accent);
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}

button .bi,
.back .bi {
  font-size: 0.92rem;
}

button[disabled] {
  opacity: 0.55;
  cursor: wait;
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
}

.small {
  padding: 0.48rem 0.7rem;
  font-size: 0.79rem;
}

.inline-form {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  text-align: left;
  padding: 0.62rem 0.3rem;
  border-bottom: 1px solid rgba(176, 197, 225, 0.08);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

td {
  font-size: 0.84rem;
}

.app-cell,
.resource-cell,
.access-cell {
  display: grid;
  gap: 0.16rem;
}

.app-cell strong {
  font-size: 0.9rem;
}

.resource-cell strong,
.access-cell strong {
  font-size: 0.8rem;
}

.resource-cell span,
.access-cell span {
  color: var(--muted);
  font-size: 0.76rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: rgba(159, 192, 255, 0.13);
  border: 1px solid rgba(159, 192, 255, 0.16);
  color: var(--text);
  font-size: 0.72rem;
}

.chip-muted {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(176, 197, 225, 0.1);
  color: var(--muted);
}

.chip-success {
  background: rgba(125, 216, 196, 0.16);
  border-color: rgba(125, 216, 196, 0.25);
  color: var(--accent-2);
}

.chip-solid {
  background: rgba(159, 192, 255, 0.22);
  border-color: rgba(159, 192, 255, 0.28);
}

.service-card {
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(13, 24, 39, 0.96), rgba(10, 19, 31, 0.92));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.service-card-empty {
  grid-column: 1 / -1;
}

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

.service-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.service-head h2 {
  display: flex;
  align-items: center;
}

.service-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.service-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(176, 197, 225, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.icon-action .bi {
  font-size: 0.9rem;
}

.icon-action:hover {
  border-color: rgba(159, 192, 255, 0.3);
  background: rgba(159, 192, 255, 0.09);
}

.ghost-action {
  background: transparent;
}

.service-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.service-meta {
  display: grid;
  gap: 0.2rem;
}

.service-meta span {
  color: var(--muted);
  font-size: 0.76rem;
}

.service-meta strong {
  color: var(--text);
  margin-right: 0.32rem;
}

.mail-policy-card {
  gap: 0.9rem;
}

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

.mail-policy-panel {
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
  border: 1px solid rgba(176, 197, 225, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.mail-policy-panel h3 {
  font-size: 0.9rem;
}

.inline-form.stacked {
  display: grid;
}

.mail-policy-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.mail-policy-alerts {
  display: grid;
  gap: 0.3rem;
  padding: 0.75rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 143, 144, 0.18);
  background: rgba(255, 143, 144, 0.05);
}

.mail-policy-alerts p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.mail-policy-alerts strong {
  color: var(--danger);
}

.mail-policy-log {
  margin-top: 0;
}

.code-card {
  display: grid;
  gap: 0.3rem;
  padding: 0.72rem 0.8rem;
  border: 1px solid rgba(176, 197, 225, 0.1);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  margin: 0.7rem 0;
}

.action-dialog {
  width: min(560px, calc(100% - 1.5rem));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: linear-gradient(180deg, rgba(13, 24, 39, 0.98), rgba(8, 16, 27, 0.98));
  color: var(--text);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

.action-dialog::backdrop {
  background: rgba(3, 8, 14, 0.7);
  backdrop-filter: blur(8px);
}

.action-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 0.95rem;
  border-bottom: 1px solid rgba(176, 197, 225, 0.08);
}

.action-dialog-body {
  padding: 0.9rem 0.95rem 1rem;
}

.action-status {
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
  color: var(--accent-2);
}

.action-log {
  margin: 0;
  min-height: 160px;
  max-height: 42vh;
  overflow: auto;
  background: rgba(255, 255, 255, 0.03);
}

pre,
code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

pre {
  margin: 0.6rem 0 0;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(176, 197, 225, 0.08);
  border-radius: 10px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

code {
  color: var(--accent-2);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.code-card code {
  white-space: pre-wrap;
}

.ok {
  color: var(--accent-2);
}

.err {
  color: var(--danger);
}

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

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

  .mail-policy-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .hero-head,
  .section-head,
  .fold summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }
}

.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.theme-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.theme-option .bi {
  font-size: 0.95rem;
}

.theme-option:hover {
  border-color: var(--accent);
}

.theme-option.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--btn-on-accent);
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.18);
}

[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(10, 132, 255, 0.10), transparent 28rem),
    linear-gradient(180deg, #f5f5f7 0%, #ffffff 100%);
}

[data-theme="light"] .attention-card {
  background: linear-gradient(180deg, #ffffff, #fbfbfd);
}

[data-theme="light"] .attention-item {
  background: rgba(60, 67, 90, 0.04);
  border-color: rgba(60, 67, 90, 0.10);
}

[data-theme="light"] .meter {
  background: rgba(60, 67, 90, 0.10);
}

[data-theme="light"] input,
[data-theme="light"] select {
  background: #ffffff;
  border-color: rgba(60, 67, 90, 0.16);
}

[data-theme="light"] input[readonly] {
  color: #0a84ff;
  background: rgba(10, 132, 255, 0.06);
}

[data-theme="light"] .ghost {
  background: transparent;
}

[data-theme="light"] .subtle {
  background: rgba(60, 67, 90, 0.05);
  color: var(--text);
}

[data-theme="light"] .ghost,
[data-theme="light"] .subtle {
  color: var(--text);
}

[data-theme="light"] .card-soft {
  background: linear-gradient(180deg, #ffffff, #fbfbfd);
}

[data-theme="light"] .fold-body {
  border-top-color: rgba(60, 67, 90, 0.08);
}

[data-theme="light"] th,
[data-theme="light"] td {
  border-bottom-color: rgba(60, 67, 90, 0.08);
}

[data-theme="light"] .chip {
  background: rgba(10, 132, 255, 0.10);
  border-color: rgba(10, 132, 255, 0.22);
  color: #0a84ff;
}

[data-theme="light"] .chip-muted {
  background: rgba(60, 67, 90, 0.05);
  border-color: rgba(60, 67, 90, 0.10);
  color: var(--muted);
}

[data-theme="light"] .chip-success {
  background: rgba(48, 178, 122, 0.14);
  border-color: rgba(48, 178, 122, 0.26);
  color: #1e8e5f;
}

[data-theme="light"] .chip-solid {
  background: rgba(10, 132, 255, 0.16);
  border-color: rgba(10, 132, 255, 0.28);
  color: #0a84ff;
}

[data-theme="light"] .service-card {
  background: linear-gradient(180deg, #ffffff, #fbfbfd);
}

[data-theme="light"] .icon-action {
  border-color: rgba(60, 67, 90, 0.14);
  background: rgba(60, 67, 90, 0.04);
  color: var(--text);
}

[data-theme="light"] .icon-action:hover {
  border-color: rgba(10, 132, 255, 0.32);
  background: rgba(10, 132, 255, 0.08);
}

[data-theme="light"] .mail-policy-panel {
  background: #ffffff;
  border-color: rgba(60, 67, 90, 0.12);
}

[data-theme="light"] .mail-policy-alerts {
  background: rgba(255, 59, 48, 0.06);
  border-color: rgba(255, 59, 48, 0.22);
}

[data-theme="light"] .code-card {
  background: #ffffff;
  border-color: rgba(60, 67, 90, 0.12);
}

[data-theme="light"] .action-dialog {
  background: linear-gradient(180deg, #ffffff, #fbfbfd);
  color: var(--text);
  box-shadow: 0 18px 60px rgba(60, 67, 90, 0.22);
}

[data-theme="light"] .action-dialog::backdrop {
  background: rgba(60, 67, 90, 0.35);
}

[data-theme="light"] .action-dialog-head {
  border-bottom-color: rgba(60, 67, 90, 0.08);
}

[data-theme="light"] .action-log,
[data-theme="light"] pre {
  background: #fbfbfd;
  border-color: rgba(60, 67, 90, 0.10);
}

[data-theme="light"] code {
  color: #1e8e5f;
}

@media (max-width: 720px) {
  .layout {
    width: min(100% - 0.75rem, 1160px);
  }

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

  .tabbar {
    display: inline-flex;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabbar::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    min-width: 122px;
  }

  .card,
  .fold summary,
  .fold-body,
  .metric-card,
  .summary-card,
  .hero-head,
  .service-card {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  th,
  td {
    padding: 0.56rem 0.24rem;
  }
}
