:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #eef3f5;
  --line: #d8e0e4;
  --line-strong: #bdc8ce;
  --text: #182329;
  --muted: #63737c;
  --primary: #176b87;
  --primary-strong: #0f5368;
  --danger: #b42318;
  --warning: #a15c07;
  --success: #0f7a4f;
  --shadow: 0 16px 42px rgba(29, 43, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-box {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-info {
  padding: 34px;
  background: #19333b;
  color: white;
}

.auth-info h1 {
  margin: 0 0 16px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
}

.auth-info p {
  margin: 0;
  color: #d9e5e9;
  line-height: 1.6;
}

.auth-panel {
  padding: 34px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button,
.nav-button {
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  padding: 9px 12px;
  min-height: 38px;
}

.tab-button.active,
.nav-button.active {
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(20, 32, 38, 0.08);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.primary {
  background: var(--primary);
  color: #fff;
}

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

.secondary {
  background: #e1eaee;
  color: #16313a;
}

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

.ghost {
  background: transparent;
  color: var(--primary);
}

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

.sidebar {
  background: #17313a;
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  font-weight: 800;
  font-size: 18px;
}

.mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dcebef;
  color: #17313a;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  text-align: left;
  color: #d6e5e9;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: none;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.user-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.user-text {
  min-width: 0;
  text-align: right;
}

.user-text strong,
.user-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.toolbar .actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search {
  max-width: 360px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

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

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 16px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  background: #f8fafb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status.active,
.status.connected,
.status.shared {
  background: #dff4ea;
  color: var(--success);
}

.status.inactive,
.status.private {
  background: #eef2f4;
  color: #53646c;
}

.status.warning {
  background: #fff0d8;
  color: var(--warning);
}

.status.danger {
  background: #fde6e3;
  color: var(--danger);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #f8fafb;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: #34464f;
  overflow-wrap: anywhere;
}

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

.error,
.notice {
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 14px;
}

.error {
  background: #fde6e3;
  color: var(--danger);
}

.notice {
  background: #e3f0f5;
  color: #174b5c;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 29, 35, 0.42);
  z-index: 20;
}

.modal {
  width: min(720px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

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

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

.checkbox {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 40px;
}

.checkbox input {
  width: 18px;
  min-height: 18px;
}

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

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

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

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

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

@media (max-width: 620px) {
  .auth-page,
  .content,
  .topbar {
    padding: 14px;
  }

  .auth-info,
  .auth-panel {
    padding: 22px;
  }

  .topbar,
  .toolbar,
  .panel-header,
  .modal-header,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .user-menu {
    justify-content: space-between;
  }

  .user-text {
    text-align: left;
  }

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