:root {
  color-scheme: light;
  --ink: #102537;
  --muted: #66798a;
  --line: #dce5e9;
  --soft: #f1f5f5;
  --paper: #fbfdfc;
  --white: #ffffff;
  --navy: #081b2b;
  --navy-2: #102e42;
  --teal: #0c8078;
  --teal-dark: #08635e;
  --mint: #d9f2ea;
  --amber: #b76a09;
  --amber-soft: #fff0d8;
  --red: #b83b45;
  --red-soft: #fee9e8;
  --blue-soft: #e7f0fb;
  --shadow: 0 18px 50px rgba(14, 42, 59, 0.08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--soft); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(12, 128, 120, 0.11), transparent 28rem),
    var(--soft);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(12, 128, 120, 0.25);
  outline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px 22px;
  color: #d9e4e8;
  background:
    linear-gradient(160deg, rgba(18, 73, 81, 0.3), transparent 40%),
    var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
  padding: 0 8px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-weight: 800;
  font-size: 21px;
  color: var(--navy);
  background: linear-gradient(145deg, #79d4c4, #d9f2ea);
  box-shadow: 0 8px 24px rgba(69, 207, 184, 0.18);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: 0.01em; }
.brand small { margin-top: 2px; color: #8fa8b4; font-size: 11px; letter-spacing: 0.13em; }

.navigation { display: grid; gap: 7px; margin-top: 28px; }
.nav-item {
  border: 0;
  border-radius: 12px;
  padding: 12px 13px;
  color: #9db1bb;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: 160ms ease;
}
.nav-item:hover { color: white; background: rgba(255, 255, 255, 0.06); }
.nav-item.is-active { color: white; background: rgba(49, 177, 160, 0.16); }
.nav-item.is-active .nav-icon { color: #78d4c6; }
.nav-icon { width: 22px; text-align: center; font-size: 20px; }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.09); padding: 20px 8px 0; }
.security-note { display: flex; align-items: center; gap: 10px; }
.security-note strong, .security-note small { display: block; }
.security-note strong { color: #e9f2f4; font-size: 12px; }
.security-note small { margin-top: 3px; color: #75909e; font-size: 10px; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: #48c4a8; box-shadow: 0 0 0 5px rgba(72, 196, 168, 0.11); }
.sidebar-foot .text-button { margin-top: 20px; color: #8fa8b4; }

.main { min-width: 0; }
.topbar {
  min-height: 92px;
  padding: 19px 34px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  background: rgba(251, 253, 252, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 15;
}
.topbar h1 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(23px, 2.2vw, 31px); font-weight: 600; }
.eyebrow { margin: 0; color: var(--teal); font-size: 10px; line-height: 1.2; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.environment-picker { display: flex; align-items: center; gap: 9px; padding: 7px 8px 7px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.environment-picker span { color: var(--muted); font-size: 11px; }
.environment-picker select { border: 0; color: var(--ink); background: transparent; font-weight: 700; }
.icon-button, .menu-button, .close-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--white);
  border-radius: 12px;
}
.icon-button { width: 42px; height: 42px; font-size: 20px; }
.menu-button { display: none; width: 42px; height: 42px; }
.service-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.service-status span { width: 8px; height: 8px; border-radius: 50%; background: #9daab1; }
.service-status.is-online span { background: #2eaa80; }
.service-status.is-offline span { background: var(--red); }

.content { padding: 30px 34px 50px; max-width: 1600px; margin: 0 auto; }
.view { display: none; animation: rise 240ms ease; }
.view.is-visible { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero-panel {
  overflow: hidden;
  min-height: 190px;
  padding: 38px 40px;
  border-radius: 24px;
  color: #e7f1f2;
  background:
    radial-gradient(circle at 88% 20%, rgba(64, 197, 175, 0.22), transparent 18rem),
    linear-gradient(125deg, var(--navy), var(--navy-2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}
.hero-panel h2 { margin: 10px 0; max-width: 640px; color: white; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(28px, 4vw, 48px); line-height: 1.05; }
.hero-panel p:not(.eyebrow) { margin: 0; max-width: 580px; color: #aabfc7; line-height: 1.6; }
.hero-environment { border: 1px solid rgba(121, 212, 196, 0.35); border-radius: 999px; padding: 10px 16px; color: #9ee5d8; background: rgba(8, 27, 43, 0.35); font-size: 10px; font-weight: 900; letter-spacing: 0.15em; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.metric-card, .panel { border: 1px solid rgba(207, 220, 224, 0.9); background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); }
.metric-card { padding: 22px; border-radius: var(--radius); }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 8px 0 3px; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 600; }
.metric-card small { color: #8796a0; font-size: 10px; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(330px, 0.7fr); gap: 20px; }
.section-grid { display: grid; grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr); gap: 20px; align-items: start; }
.panel { border-radius: var(--radius); overflow: hidden; }
.panel-head { min-height: 77px; padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 4px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 600; }
.counter { min-width: 35px; padding: 6px 9px; text-align: center; border-radius: 999px; color: var(--teal-dark); background: var(--mint); font-size: 11px; font-weight: 800; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 12px 18px; color: #7d8e98; background: #f7f9f9; font-size: 9px; text-align: left; text-transform: uppercase; letter-spacing: 0.12em; }
td { padding: 16px 18px; border-top: 1px solid #edf1f2; font-size: 12px; }
tbody tr:hover { background: #fbfdfd; }
.empty-cell { padding: 34px 18px; color: var(--muted); text-align: center; }
.company-cell strong, .company-cell small { display: block; }
.company-cell small { margin-top: 3px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.good { color: #13775c; background: var(--mint); }
.badge.warn { color: var(--amber); background: var(--amber-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }
.badge.neutral { color: #567083; background: var(--blue-soft); }
.environment-tag { color: #41596a; font-weight: 700; text-transform: capitalize; }
.dte-code { display: inline-grid; place-items: center; min-width: 31px; height: 27px; padding: 0 7px; border-radius: 8px; color: var(--navy); background: #e8eeee; font-weight: 800; }

.activity-list { padding: 8px 20px; }
.activity-item { padding: 16px 2px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; border-bottom: 1px solid #edf1f2; }
.activity-item:last-child { border: 0; }
.activity-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--teal-dark); background: var(--mint); }
.activity-item strong, .activity-item small { display: block; }
.activity-item strong { font-size: 12px; }
.activity-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.form-panel { position: sticky; top: 122px; }
.form-grid { display: grid; gap: 16px; padding: 22px; }
.form-grid label, .dialog-card label { display: grid; gap: 7px; color: #4d6575; font-size: 11px; font-weight: 700; }
.form-grid input, .form-grid select, .dialog-card input {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid #cedade;
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
}
.form-grid input:focus, .form-grid select:focus, .dialog-card input:focus { border-color: var(--teal); outline: 3px solid rgba(12, 128, 120, 0.1); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.switch-field { display: flex !important; grid-template-columns: auto auto 1fr; align-items: center; gap: 9px !important; }
.switch-field input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 20px; padding: 2px; border-radius: 999px; background: #bac7cb; transition: 160ms ease; }
.switch::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: white; transition: 160ms ease; }
.switch-field input:checked + .switch { background: var(--teal); }
.switch-field input:checked + .switch::after { transform: translateX(16px); }

.primary-button, .secondary-button, .text-button, .table-button { border: 0; font-weight: 800; }
.primary-button { min-height: 44px; padding: 11px 17px; border-radius: 11px; color: white; background: var(--teal); box-shadow: 0 10px 24px rgba(12, 128, 120, 0.18); }
.primary-button:hover { background: var(--teal-dark); }
.secondary-button { padding: 9px 13px; border-radius: 9px; color: var(--teal-dark); background: var(--mint); font-size: 10px; }
.text-button { padding: 3px 0; color: var(--teal); background: transparent; font-size: 10px; }
.table-button { padding: 7px 9px; border-radius: 8px; color: var(--teal-dark); background: var(--mint); font-size: 9px; }
.table-button + .table-button { margin-left: 5px; }
.table-button.upload { color: #6f5415; background: #fff0cc; }
button[disabled] { opacity: 0.55; cursor: wait; }

.card-list { padding: 8px 20px; }
.entity-card { padding: 18px 2px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid #edf1f2; }
.entity-card:last-child { border: 0; }
.entity-avatar { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--teal-dark); background: var(--mint); font-family: Georgia, serif; font-size: 19px; }
.entity-card strong, .entity-card small { display: block; }
.entity-card small { margin-top: 4px; color: var(--muted); }
.entity-card .badge { margin-left: auto; }

.dialog { width: min(540px, calc(100vw - 30px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: transparent; box-shadow: 0 30px 80px rgba(2, 17, 28, 0.28); }
.dialog::backdrop { background: rgba(4, 18, 29, 0.62); backdrop-filter: blur(4px); }
.dialog-card { padding: 25px; border-radius: 20px; background: white; display: grid; gap: 17px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-head h2 { margin: 5px 0 0; font-family: Georgia, serif; font-size: 25px; }
.dialog-copy { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.close-button { width: 34px; height: 34px; font-size: 20px; }
.action-content { display: grid; gap: 13px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.action-content ol { margin: 0; padding-left: 20px; }
.action-content a { color: var(--teal); font-weight: 800; }
.upload-box { padding: 15px; border: 1px dashed #b9cbcf; border-radius: 12px; background: #f7fafa; }
.upload-box input { margin: 10px 0; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 10px; }
.toast { max-width: 380px; padding: 13px 16px; border-radius: 12px; color: white; background: var(--navy); box-shadow: 0 15px 45px rgba(4, 20, 31, 0.25); font-size: 12px; animation: toast-in 200ms ease; }
.toast.error { background: #8e2932; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .section-grid { grid-template-columns: 1fr; }
  .form-panel { position: static; }
}

@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 260px; transition: 180ms ease; box-shadow: 20px 0 50px rgba(4, 20, 31, 0.28); }
  .sidebar.is-open { transform: none; }
  .menu-button { display: block; }
  .topbar { padding: 14px 18px; }
  .topbar > div:nth-child(2) { flex: 1; }
  .topbar .eyebrow, .service-status { display: none; }
  .environment-picker span { display: none; }
  .content { padding: 20px 16px 40px; }
  .hero-panel { min-height: 230px; padding: 28px; align-items: flex-start; flex-direction: column; gap: 22px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 17px; }
  .metric-card strong { font-size: 27px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 21px; }
  .environment-picker { padding-left: 8px; }
}
