:root {
  color-scheme: dark;
  --bg: #0d1115;
  --bg-soft: #111820;
  --panel: #151b22;
  --panel-2: #1b232c;
  --panel-3: #222c36;
  --line: #2a3541;
  --line-strong: #384656;
  --text: #f4f7fa;
  --muted: #9ba8b5;
  --soft: #c6d0da;
  --accent: #25d0aa;
  --accent-dark: #0f5f51;
  --yellow: #f1bd5f;
  --red: #ef7669;
  --blue: #77a8ff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(37, 208, 170, 0.16), transparent 28%),
    linear-gradient(145deg, #0c1014 0%, #121922 100%);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(21, 27, 34, 0.94);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 62px;
  height: 62px;
  object-fit: contain;
}

.login-card p,
.login-card h1 {
  margin: 0;
}

.login-card p {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.login-card h1 {
  font-size: 2.1rem;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f151b;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(37, 208, 170, 0.76);
  box-shadow: 0 0 0 3px rgba(37, 208, 170, 0.12);
}

.primary-action,
.logout-button,
.open-link,
.save-user,
.quick-action,
.quick-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  text-decoration: none;
}

.primary-action {
  border: 0;
  background: var(--accent);
  color: #052720;
  font-weight: 850;
}

.primary-action:hover {
  background: #38dfbb;
}

.form-message {
  min-height: 18px;
  color: var(--yellow);
  font-size: 0.88rem;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #121820 0%, #0f141a 100%);
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.module-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover {
  border-color: rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.nav-item.is-active {
  border-color: rgba(37, 208, 170, 0.36);
  background: rgba(37, 208, 170, 0.12);
  color: var(--text);
}

.nav-item.is-active .nav-icon {
  background: var(--accent);
  color: #06241f;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #202a34;
  color: var(--yellow);
  font-size: 0.74rem;
  font-weight: 850;
}

.logout-button {
  margin-top: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.logout-button:hover,
.open-link:hover,
.save-user:hover,
.quick-action:hover,
.quick-link:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.main-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 88px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 32, 0.94);
}

.topbar p,
.topbar h1,
.dashboard-hero p,
.dashboard-hero h2,
.dashboard-panel p,
.dashboard-panel h2 {
  margin: 0;
}

.topbar p,
.dashboard-hero p,
.dashboard-panel p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h1 {
  margin-top: 3px;
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  letter-spacing: 0;
}

.open-link,
.quick-action {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  white-space: nowrap;
}

.dashboard-view {
  display: grid;
  gap: 18px;
  padding: 22px;
  overflow: auto;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(37, 208, 170, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(37, 208, 170, 0.16), transparent 48%),
    linear-gradient(180deg, #172028, #131a22);
}

.dashboard-hero h2 {
  margin-top: 4px;
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  letter-spacing: 0;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.metric-card,
.dashboard-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 130px;
  padding: 16px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-card strong {
  font-size: 2.1rem;
  letter-spacing: 0;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.dashboard-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
}

.dashboard-panel h2 {
  margin-top: 3px;
  font-size: 1.25rem;
}

.quick-links,
.activity-list {
  display: grid;
  gap: 10px;
}

.quick-link {
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #10161d;
  color: var(--text);
  text-align: left;
}

.quick-link span,
.quick-link small {
  display: block;
}

.quick-link small,
.activity-item small {
  color: var(--muted);
}

.activity-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #10161d;
}

.activity-item span {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.activity-item strong {
  overflow-wrap: anywhere;
}

.module-frame-wrap {
  min-height: 0;
  background: #0b0f13;
}

iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 88px);
  border: 0;
  background: #101418;
}

.users-dialog {
  width: min(1080px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.users-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.dialog-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.dialog-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dialog-panel p,
.dialog-panel h2,
.dialog-panel h3 {
  margin: 0;
}

.dialog-panel p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.icon-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161d;
  color: var(--text);
}

.users-list {
  display: grid;
  gap: 10px;
  max-height: 54vh;
  overflow: auto;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) 120px minmax(280px, 2fr) minmax(160px, 0.8fr) 104px;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161d;
}

.user-main strong,
.user-main span {
  display: block;
}

.user-main span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.permission-grid label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--soft);
  font-size: 0.84rem;
}

.permission-grid input {
  min-height: 18px;
  width: 18px;
  accent-color: var(--accent);
}

.save-user {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.new-user {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr) 110px;
  gap: 10px;
  align-items: end;
  padding-top: 8px;
}

.new-user h3 {
  grid-column: 1 / -1;
}

.empty-state {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
}

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

@media (max-width: 920px) {
  .workspace-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 14px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    grid-template-columns: 38px minmax(0, 1fr);
    padding-bottom: 10px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

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

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 5px;
    min-height: 68px;
    text-align: center;
  }

  .logout-button {
    margin-top: 0;
  }

  .topbar {
    min-height: 76px;
    padding: 14px;
  }

  .open-link {
    display: none;
  }

  .dashboard-view {
    padding: 14px;
  }

  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

  iframe {
    min-height: calc(100vh - 322px);
  }

  .user-row,
  .new-user {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .login-card {
    padding: 22px;
  }

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

  .nav-item {
    grid-template-columns: 34px minmax(0, 1fr);
    justify-items: stretch;
    min-height: 48px;
    text-align: left;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
