:root {
  --bg: #f5f8fc;
  --panel: #ffffff;
  --panel-soft: #f8fafd;
  --line: #d9e1ec;
  --line-strong: #c9d4e4;
  --text: #0f172a;
  --muted: #64748b;
  --blue: #075ccc;
  --blue-strong: #034fb5;
  --blue-soft: #eaf2ff;
  --green: #16a34a;
  --green-soft: #e9fbea;
  --orange: #f59e0b;
  --orange-soft: #fff7e6;
  --red: #ef4444;
  --nav: #102033;
  --nav-deep: #081827;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef4fb 0%, #f5f8fc 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
}

.login-brand p {
  margin: 6px 0 0;
  color: var(--muted);
}

.login-fields {
  display: grid;
  gap: 16px;
}

.login-fields label {
  display: grid;
  gap: 8px;
  color: #172033;
  font-weight: 600;
}

.login-fields input {
  min-height: 48px;
  padding: 0 15px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.login-message {
  margin: 0;
  min-height: 20px;
  color: var(--red);
  font-size: 14px;
  line-height: 1.5;
}

.login-message:empty {
  min-height: 0;
}

.login-message.success {
  color: var(--green);
}

.login-submit {
  width: 100%;
  min-height: 46px;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, var(--nav), var(--nav-deep));
  color: #f8fafc;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.22);
  z-index: 4;
  overflow: hidden;
}

.brand {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  font-size: 25px;
  font-weight: 750;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 34px;
  height: 34px;
  color: #1d78e6;
}

.brand-mark svg,
[data-icon] svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}

.nav {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  padding: 24px 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(203, 213, 225, 0.55) transparent;
}

.nav::-webkit-scrollbar,
.sidebar-footer::-webkit-scrollbar {
  width: 8px;
}

.nav::-webkit-scrollbar-thumb,
.sidebar-footer::-webkit-scrollbar-thumb {
  background: rgba(203, 213, 225, 0.45);
  border-radius: 999px;
}

.nav::-webkit-scrollbar-track,
.sidebar-footer::-webkit-scrollbar-track {
  background: transparent;
}

.nav-title {
  margin: 0 14px 12px;
  color: #cbd5e1;
  font-size: 12px;
  text-transform: uppercase;
}

.nav-item {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-radius: 6px;
  color: #f8fafc;
  text-decoration: none;
  font-size: 16px;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(90deg, #1167d8, #0754c1);
}

.nav-item.locked,
.nav-item.locked:hover,
.nav-item.locked:focus-visible {
  background: transparent;
  color: rgba(248, 250, 252, 0.6);
  opacity: 0.72;
  cursor: not-allowed;
}

.nav-item.locked [data-icon] {
  color: rgba(203, 217, 235, 0.55);
}

.nav-item.locked::after {
  content: "Locked";
  margin-left: auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: rgba(203, 213, 225, 0.72);
}

.nav-item [data-icon] {
  width: 23px;
  height: 23px;
  color: #cbd9eb;
  flex: 0 0 auto;
}

.nav-item.active [data-icon] {
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}

.version {
  margin: 22px 14px 0;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.55;
}

.main {
  min-width: 0;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.05);
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 760;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.date-chip,
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #172033;
  white-space: nowrap;
}

.role-switcher {
  width: auto;
  min-height: 34px;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 13px;
  font-weight: 700;
}

.date-chip {
  min-height: 36px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.date-chip [data-icon],
.account [data-icon] {
  width: 19px;
  height: 19px;
  color: #475569;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #263f97;
  color: #fff;
  font-weight: 750;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #334155;
  border-radius: 6px;
}

.icon-button:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.icon-button [data-icon],
.icon-button > [data-icon] {
  width: 22px;
  height: 22px;
}

.menu-button {
  display: none;
}

.notification {
  position: relative;
}

.notification b {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 12px;
}

.content {
  padding: 28px 34px 34px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}

.page-heading h2 {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.15;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  min-height: 126px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
}

.summary-card strong {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.summary-card small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dashboard-panel {
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dashboard-panel-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f9fbfe, #f2f6fb);
}

.dashboard-panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.dashboard-panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-list {
  display: grid;
  gap: 0;
}

.dashboard-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.dashboard-row:last-child {
  border-bottom: 0;
}

.dashboard-main {
  display: grid;
  gap: 4px;
}

.dashboard-main strong {
  font-size: 16px;
}

.dashboard-main span,
.dashboard-meta small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dashboard-meta {
  display: grid;
  justify-items: start;
  gap: 6px;
}

.dashboard-empty {
  padding: 18px 20px;
  color: var(--muted);
  font-weight: 600;
}

.search-box {
  width: min(400px, 42vw);
  height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--text);
}

.search-box [data-icon] {
  width: 22px;
  height: 22px;
  color: #334155;
}

.primary-button,
.secondary-button,
.danger-button,
.back-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 650;
}

.dashboard-view {
  display: block;
}

.primary-button {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(7, 92, 204, 0.24);
}

.primary-button:hover {
  background: var(--blue-strong);
}

.secondary-button,
.back-button {
  background: #fff;
  color: #0f172a;
  border-color: var(--line-strong);
}

.secondary-button:hover,
.back-button:hover {
  border-color: #9db4d4;
  background: #f7fbff;
}

.danger-button {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button [data-icon],
.secondary-button [data-icon],
.danger-button [data-icon],
.back-button [data-icon] {
  width: 19px;
  height: 19px;
}

.data-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

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

.user-table {
  min-width: 760px;
}

th,
td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 15px;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  height: 56px;
  background: linear-gradient(180deg, #f9fbfe, #f0f4f9);
  color: #0f172a;
  font-weight: 750;
}

.sort-trigger {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 750;
  padding: 0;
  text-align: left;
}

.sort-trigger:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
  border-radius: 4px;
}

.sort-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: transform 160ms ease, color 160ms ease, opacity 160ms ease;
  opacity: 0.65;
}

.sort-trigger.is-active .sort-icon {
  color: var(--blue);
  opacity: 1;
}

.sort-trigger.ascending .sort-icon {
  transform: rotate(180deg);
}

.sort-trigger.descending .sort-icon {
  transform: rotate(0deg);
}

td {
  height: 70px;
  background: #fff;
}

.empty-state {
  height: 130px;
  text-align: center;
  color: var(--muted);
  font-weight: 650;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover td,
tbody tr.selected td {
  background: #f7fbff;
}

.cid-link {
  border: 0;
  background: transparent;
  color: #004fbe;
  font-weight: 780;
  padding: 0;
}

.note-cell {
  max-width: 230px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 7px;
  padding: 0 10px;
  font-size: 14px;
  border: 1px solid currentColor;
}

.badge.active {
  color: var(--green);
  background: var(--green-soft);
}

.badge.warning {
  color: var(--orange);
  background: var(--orange-soft);
}

.badge.down {
  color: var(--red);
  background: #fff0f0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 7px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid currentColor;
}

.role-badge.manager {
  color: #075ccc;
  background: #eaf2ff;
}

.role-badge.viewer {
  color: #64748b;
  background: #f1f5f9;
}

.mrtg-thumb {
  width: 150px;
  height: 48px;
  display: block;
  border: 1px solid var(--line-strong);
  background: #fefefe;
}

img.mrtg-thumb {
  object-fit: cover;
}

.actions {
  display: flex;
  gap: 10px;
}

.readonly-note {
  color: var(--muted);
  font-weight: 650;
}

.action-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: #fff;
}

.action-btn [data-icon] {
  width: 18px;
  height: 18px;
}

.action-view {
  background: #095fcf;
}

.action-edit {
  background: #f59e0b;
}

.action-delete {
  background: #ef4444;
}

.table-footer {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  color: #334155;
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pagination button.current {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.pagination .ellipsis {
  min-width: 28px;
  text-align: center;
  color: var(--muted);
}

.pagination [data-icon] {
  width: 17px;
  height: 17px;
  margin: 0 auto;
}

.detail-panel {
  display: grid;
  grid-template-columns: 405px minmax(0, 1fr);
  margin-top: 24px;
}

.detail-summary {
  background: linear-gradient(90deg, #ffffff, #f7fbff);
  border-right: 1px solid var(--line);
}

.detail-summary h3 {
  min-height: 63px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  color: #0754c1;
  font-size: 22px;
}

dl {
  margin: 0;
  padding: 20px 24px 26px;
}

.detail-row {
  display: grid;
  grid-template-columns: 140px 16px 1fr;
  gap: 8px;
  min-height: 36px;
  align-items: start;
  font-size: 15px;
}

dt {
  font-weight: 760;
}

dd {
  margin: 0;
  color: #1f2937;
}

.detail-empty {
  padding: 20px 24px;
  color: var(--muted);
  font-weight: 600;
}

.detail-main {
  min-width: 0;
}

.tabs {
  min-height: 63px;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-width: 112px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #475569;
  font-weight: 600;
  padding: 0 10px;
}

.tab.active {
  color: #0754c1;
  border-bottom-color: #0754c1;
}

.back-button {
  margin: auto 8px auto auto;
  min-height: 40px;
}

.tab-content {
  padding: 22px 30px 26px;
}

.tab-content h4 {
  margin: 0 0 14px;
  font-size: 18px;
}

.chart-frame {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  overflow: hidden;
}

.mrtg-full-image {
  width: 100%;
  max-height: 420px;
  display: block;
  object-fit: contain;
  background: #fff;
}

#mainChart {
  width: 100%;
  height: auto;
  min-height: 265px;
  display: block;
}

.chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
}

.last-update {
  color: #1f2937;
}

.info-list {
  display: grid;
  gap: 12px;
}

.info-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
  z-index: 10;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.bulk-modal {
  width: min(880px, 100%);
}

.confirm-modal {
  width: min(520px, 100%);
}

.modal-head {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 23px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
}

.bulk-body {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.confirm-body {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.confirm-body p {
  margin: 0;
  color: #334155;
}

.bulk-help {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
}

input[type="file"] {
  padding: 9px 12px;
}

.field-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.upload-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

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

.upload-preview img {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
}

textarea {
  resize: vertical;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 22px 22px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand span:last-child,
  .nav-title,
  .nav-item:not(.active) {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .sidebar-footer .version {
    display: none;
  }

  .page-heading,
  .detail-panel {
    display: block;
  }

  .toolbar {
    margin-top: 18px;
    justify-content: flex-start;
  }

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

  .search-box {
    width: min(100%, 520px);
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    height: auto;
    position: static;
  }

  .brand {
    justify-content: flex-start;
    padding: 0 18px;
  }

  .brand span:last-child,
  .nav-item:not(.active) {
    font-size: 16px;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .nav-title,
  .sidebar-footer {
    display: none;
  }

  .nav-item {
    justify-content: flex-start;
    min-height: 46px;
    padding: 0 12px;
  }

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

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

  .dashboard-panel-head,
  .dashboard-row {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 16px;
  }

  .topbar-actions {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
  }

  .date-chip {
    border-left: 0;
    padding-left: 0;
    white-space: normal;
  }

  .content {
    padding: 20px 14px;
  }

  .page-heading h2 {
    font-size: 24px;
  }

  .toolbar,
  .search-box,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .table-footer,
  .chart-foot,
  .tabs {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    padding: 0 14px 12px;
  }

  .tab {
    min-height: 42px;
    width: 100%;
    text-align: left;
  }

  .back-button {
    width: 100%;
    margin: 0;
  }

  .detail-summary h3 {
    font-size: 19px;
  }

  .detail-row {
    grid-template-columns: 112px 10px 1fr;
    font-size: 14px;
  }

  .tab-content {
    padding: 18px 14px;
  }

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

  .upload-preview {
    grid-template-columns: 1fr;
  }
}
