:root {
  color-scheme: light;
  --accent: #7132f5;
  --accent-dark: #5741d8;
  --accent-deep: #5b1ecf;
  --accent-subtle: rgba(133, 91, 251, 0.16);
  --text: #101114;
  --muted: #9497a9;
  --muted-strong: #686b82;
  --line: #dedee5;
  --bg: #f8f9fc;
  --surface: #ffffff;
  --ok: #149e61;
  --ok-bg: rgba(20, 158, 97, 0.16);
  --ok-text: #026b3f;
  --warn: #b45309;
  --warn-bg: rgba(180, 83, 9, 0.12);
  --bad: #b91c1c;
  --bad-bg: rgba(185, 28, 28, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.03);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.38 'IBM Plex Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
p, small { color: var(--muted); }

.shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  overflow: hidden;
  color: #fff;
  background: var(--text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand p, .sidebar small { color: rgba(255, 255, 255, 0.65); }

.logo {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  width: 160px;
  height: 80px;
  background: transparent;
}
.logo img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }

nav { display: grid; flex: 1; align-content: start; gap: 4px; overflow-y: auto; padding-right: 3px; }

.navLink {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  text-align: left;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  box-shadow: none;
  cursor: pointer;
}

.navLink.active { background: var(--accent-subtle); color: #fff; }
.navLink:hover { background: rgba(255, 255, 255, 0.08); }

.sidebarAccount { flex: 0 0 auto; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); }
.accountIdentity { display: flex; align-items: center; gap: 10px; padding: 0 8px 10px; }
.accountIdentity > span:last-child { display: grid; min-width: 0; }
.accountIdentity strong { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.accountAvatar { display: grid; flex: 0 0 auto; width: 30px; height: 30px; place-items: center; border-radius: var(--radius-sm); background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
.accountButtons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.accountButton { display: flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 8px; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); background: transparent; color: rgba(255,255,255,.8); font-size: 12px; font-weight: 400; box-shadow: none; cursor: pointer; }
.accountButton:hover, .accountButton.active { background: rgba(255,255,255,.1); }

main {
  padding: 24px 28px 42px;
  min-width: 0;
}

.view { display: none; }
.view.active { display: block; }

.topbar, .toolbar, .panelHeader, .rowActions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 20px;
}

.pageHeading { display: grid; gap: 3px; }
.pageTitleRow { display: flex; align-items: center; gap: 10px; }
.scopeLabel { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--accent-subtle); color: var(--accent-dark); font-size: 11px; font-weight: 500; }
.topbarActions { display: flex; align-items: center; gap: 10px; }
.segmented { display: flex; height: 42px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); }
.segmented button { height: 32px; padding: 0 16px; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; box-shadow: none; cursor: pointer; }
.segmented button.active { background: var(--accent); color: #fff; }
.toolbar { padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.85); box-shadow: var(--shadow); }
.toolbar input { height: 34px; border: 0; background: transparent; }
.toolbar input:focus { box-shadow: none; }
.toolbar button { height: 34px; }

input {
  height: 40px;
  min-width: 260px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

td input, td select {
  min-width: 0;
  width: 100%;
  height: 32px;
  font-size: 13px;
}

select {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.credentialCell {
  display: grid;
  grid-template-columns: 92px minmax(180px, 1fr);
  gap: 8px;
}

.companyInputs { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(170px, 1.2fr); gap: 7px; }
.addCompanyRow td { background: #f8fbfa; }

.newConfigRow td {
  background: #f7fcfb;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

.authScreen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: linear-gradient(145deg, #f5f3ff 0%, #faf9ff 52%, #f3f0ff 100%);
}
.authPanel { width: min(100%, 390px); padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.96); box-shadow: 0 18px 45px rgba(0,0,0,.06); }
.authBrand { display: flex; align-items: center; gap: 11px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.authBrand .logo { width: 200px; height: 100px; background: transparent; }
.authBrand h1 { color: var(--accent); }
.authBrand p { font-size: 12px; }
.authForm { display: grid; gap: 14px; padding-top: 20px; }
.authHeading { display: grid; gap: 3px; margin-bottom: 2px; }
.authHeading h2 { font-size: 18px; }
.authForm label, .settingsForm label { display: grid; gap: 6px; color: var(--muted-strong); font-size: 12px; }
.authForm input, .settingsForm input, .settingsForm select { width: 100%; min-width: 0; }
.authForm button { width: 100%; margin-top: 3px; }
.formError { padding: 9px 10px; border: 1px solid #f2c8c8; border-radius: var(--radius-sm); background: #fff4f4; color: var(--bad); font-size: 12px; }
.formHint { color: var(--muted); font-size: 11px; }

button {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

button.small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

button.secondary {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--accent-dark);
  box-shadow: none;
}

button.danger {
  background: var(--bad);
  color: white;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dashboardMetrics { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.metrics > div, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.metrics > div { position: relative; min-height: 122px; padding: 16px; overflow: hidden; }
.metrics > div::before { position: absolute; top: 0; right: 0; left: 0; height: 3px; background: var(--accent); content: ""; }
.metrics > div[data-tone="warning"]::before { background: var(--warn); }
.metrics > div[data-tone="critical"]::before { background: var(--bad); }
.metrics > div[data-tone="checked"]::before { background: var(--muted); }
.metrics > div[data-tone="mail"]::before { background: var(--accent); }
.metrics span { display: block; margin-top: 13px; font-size: 26px; font-weight: 600; line-height: 1; }
.metrics > div[data-tone="checked"] span { font-size: 15px; }
.metrics em { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; font-style: normal; }
.metricTitle { display: flex; align-items: center; justify-content: space-between; }
.metricTitle small { color: var(--muted-strong); font-size: 12px; }
.metricTitle i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--accent-subtle); color: var(--accent); font-size: 12px; font-style: normal; }
.metricCard[data-tone="warning"] .metricTitle small,
.metricCard[data-tone="critical"] .metricTitle small { color: var(--bad); }
.metricCard[data-tone="warning"] .metricTitle i { background: var(--warn-bg); color: var(--warn); }
.metricCard[data-tone="critical"] .metricTitle i { background: var(--bad-bg); color: var(--bad); }
.metricCard[data-tone="checked"] .metricTitle i { background: rgba(148,151,169,0.12); color: var(--muted-strong); }
.nasMetricSplit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 11px; }
.nasMetricSplit > div { min-width: 0; }
.nasMetricSplit > div + div { padding-left: 12px; border-left: 1px solid var(--line); }
.nasMetricSplit small { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.nasMetricSplit strong { display: block; margin-top: 3px; font-size: 22px; font-weight: 600; line-height: 1.1; }
.nasSplitCard em { margin-top: 7px; }

.panel {
  margin-top: 18px;
  overflow: hidden;
}

.panelHeader {
  justify-content: space-between;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.panelHeader h2 { font-size: 16px; font-weight: 600; }
.tableTools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.tableTools button { height: 40px; padding: 0 12px; box-shadow: none; }
.tableTools .secondary,
.downloadButton { border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.downloadButton:hover,
.tableTools .secondary:hover { background: #eef0f5; }

.trendPanel { overflow: visible; }
.trendHeader > div { display: grid; gap: 2px; }
.trendHeader h2 { font-size: 16px; }
.trendHeader span, .trendRange { color: var(--muted); font-size: 11px; }
.chartFrame { position: relative; height: 260px; padding: 14px 16px 10px; }
.chartFrame canvas { width: 100% !important; height: 100% !important; }
.chartEmpty { display: grid; height: 100%; place-items: center; color: var(--muted); font-size: 13px; }

.tableWrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f6f7fb;
}
.sortButton { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-transform: inherit; cursor: pointer; box-shadow: none; }
.sortButton span { color: var(--muted); font-size: 10px; }
.sortButton.active { color: var(--accent); }
.sortButton.active span { color: var(--accent); }

tbody tr:hover { background: #f4f2fd; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.ok { color: var(--ok-text); background: var(--ok-bg); }
.warn { color: var(--warn); background: var(--warn-bg); }
.bad { color: var(--bad); background: var(--bad-bg); }

.actions { padding: 0 16px 16px; }

.action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--text);
  color: white;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  font-size: 14px;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.companyLink { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; color: rgba(255,255,255,.8); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.companyLink.active, .companyLink:hover { background: var(--accent-subtle); color: #fff; }
.navIcon { width: 18px; text-align: center; color: rgba(255,255,255,.6); }
.navLabel { display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 10px 6px; border: 0; background: transparent; color: rgba(255,255,255,.5); font: inherit; font-size: 11px; font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: 0.5px; box-shadow: none; }
.sectionToggle { cursor: pointer; }
.sectionToggle:hover { color: #fff; }
.sectionToggle .collapseIcon { margin-left: auto; font-size: 13px; transition: transform .18s ease; }
.sectionToggle[aria-expanded="false"] .collapseIcon { transform: rotate(180deg); }
.companyNav { display: grid; gap: 2px; margin-left: 31px; padding: 0 0 7px 12px; border-left: 1px solid rgba(255,255,255,.15); }
.companyNav[hidden] { display: none !important; }
.companyLink { padding: 7px 9px; font-size: 13px; border-radius: var(--radius-sm); }
.hostingLink { display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 10px 0 20px; border: 0; border-radius: var(--radius-sm); background: transparent; color: rgba(255,255,255,.85); font: inherit; font-weight: 500; text-align: left; box-shadow: none; cursor: pointer; }
.hostingLink:hover { background: rgba(255,255,255,.08); }
.hostingLink.active { background: var(--accent-subtle); color: #fff; }
.hostingLink .collapseIcon { margin-left: auto; font-size: 14px; opacity: .75; }
.hostingLink .collapseIcon { padding: 8px 0 8px 10px; cursor: pointer; }
.hostingLink.collapsed .collapseIcon { transform: rotate(180deg); }
.companyLabel { padding-top: 10px; }
.iconButton { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted-strong); font-size: 16px; font-weight: 400; box-shadow: none; cursor: pointer; }
.iconButton:hover { background: var(--accent-subtle); color: var(--accent); }
.iconButton.disable { font-size: 13px; }
.iconButton.danger:hover { background: var(--bad-bg); color: var(--bad); }
.iconButton:disabled { cursor: not-allowed; opacity: .35; }
.iconButton:disabled:hover { background: transparent; color: var(--muted); }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; color: var(--muted); font-size: 13px; }
.pageButtons { display: flex; align-items: center; gap: 10px; }
.pageButton { height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--text); font-size: 12px; font-weight: 400; box-shadow: none; }
.pageButton:hover { border-color: var(--accent); color: var(--accent); }
.activityMeta { margin-top: 4px; color: var(--muted); font-size: 13px; }
.activityTable { width: 100%; border-collapse: collapse; font-size: 13px; }
.activityTable th, .activityTable td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.activityTable th { color: var(--muted-strong); font-weight: 600; background: #f6f7fb; }
.activityTarget { display: block; margin-top: 3px; color: var(--muted); }
.activityWhere { display: inline-flex; padding: 4px 7px; border: 1px solid rgba(133,91,251,0.2); border-radius: var(--radius-sm); background: var(--accent-subtle); color: var(--accent-dark); font-size: 11px; }
.emptyCell { color: var(--muted); text-align: center !important; }
.resourceGrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.trendPanel + .resourceGrid { margin-top: 18px; }
.resourceCard { min-height: 112px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow); }
.resourceHeader { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.resourceHeader small { color: var(--muted-strong); font-size: 12px; }
.resourceCard strong { display: block; margin-top: 13px; font-size: 20px; font-weight: 600; line-height: 1; }
.resourceCard span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.resourceCard em { overflow: hidden; color: var(--accent-dark); font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.resourceCard[data-resource] em {
  max-width: 52%;
  padding: 4px 6px;
  background: var(--accent-subtle);
  border: 1px solid rgba(133,91,251,0.2);
  border-radius: var(--radius-sm);
  color: var(--accent-dark);
}
.nasSourceCard em { padding: 4px 6px; border-radius: var(--radius-sm); background: var(--accent-subtle); color: var(--accent-dark); }
.nasSourceCard[data-status="error"] em { background: var(--bad-bg); color: var(--bad); }
.statusResource { border-top: 3px solid var(--ok); }
.suspendedResource { border-top-color: var(--bad); }
.resourceEmpty { grid-column: 1 / -1; padding: 13px; border: 1px dashed var(--line); border-radius: var(--radius-md); color: var(--muted); }
.settingsGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settingsPanel { min-width: 0; }
.settingsForm { display: grid; gap: 13px; padding: 16px; }
.settingsForm select { height: 40px; padding: 0 10px; }
.settingsForm button { justify-self: start; }

.toggleGroup {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 40px;
}
.toggleOption {
  flex: 1;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}
.toggleOption.active {
  background: var(--accent);
  color: #fff;
}
.toggleOption + .toggleOption {
  border-left: 1px solid var(--line);
}

.modalBackdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(16, 17, 20, 0.5);
}
.modalPanel { width: min(100%, 560px); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: 0 24px 60px rgba(0,0,0,.08); }
.userModalPanel { width: min(100%, 520px); }
.modalHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: #fafafa; }
.modalHeader > div { display: grid; gap: 2px; }
.modalHeader h2 { font-size: 18px; }
.modalHeader p { font-size: 12px; }
.modalClose { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--muted); font-size: 20px; font-weight: 400; box-shadow: none; cursor: pointer; }
.modalClose:hover { border-color: var(--accent); color: var(--accent); }
.accountForm { display: grid; gap: 14px; padding: 18px; }
.accountFields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.accountFields > label { display: grid; min-width: 0; gap: 6px; color: var(--muted-strong); font-size: 12px; }
.accountFields input, .accountFields select { width: 100%; min-width: 0; height: 40px; padding: 0 11px; }
.accountFields input[readonly] { background: #f5f8f7; color: var(--muted); }
.accountWide { grid-column: 1 / -1; }
.accessField { display: flex; align-items: center; gap: 18px; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.accessField legend { padding: 0 5px; color: var(--muted-strong); font-size: 12px; }
.accessField label { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 13px; }
.accessField input[type="checkbox"] { width: 15px; min-width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.modalActions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 2px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    max-height: 300px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
  }
  .topbar, .panelHeader, .toolbar, .topbarActions { align-items: stretch; flex-direction: column; }
  .metrics, .resourceGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settingsGrid { grid-template-columns: 1fr; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  input { min-width: 0; width: 100%; }
  .tableTools { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .tableTools input { flex: 1 1 100%; }
  .accountFields { grid-template-columns: 1fr; }
  .accountWide { grid-column: auto; }
}

@media (min-width: 901px) and (max-width: 1250px) {
  .dashboardMetrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#view-employees .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
#view-employees .topbarActions { width: 100%; }
#view-employees .toolbar { width: 100%; flex-wrap: wrap; }
#view-employees .toolbar input,
#view-employees .toolbar select,
#view-employees .toolbar button { font-size: 12px; height: 30px; min-width: 0; }
#view-employees .toolbar input { flex: 1 1 180px; padding: 0 10px; }
#view-employees .toolbar select { padding: 0 8px; }
#view-employees .toolbar button { padding: 0 12px; white-space: nowrap; }
