:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #647181;
  --line: #dfe5ea;
  --blue: #2754d8;
  --blue-soft: #e8eefc;
  --green: #137a55;
  --green-soft: #e8f5ef;
  --amber: #9a6500;
  --amber-soft: #fff3d7;
  --red: #b42318;
  --red-soft: #fff0ec;
  --shadow: 0 18px 45px rgba(22, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

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

.public-shell {
  min-height: 100vh;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #101820;
  color: #fff;
}

.brand,
.brand:hover {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.brand-logo.large {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(22, 32, 42, 0.14);
}

.brand small,
.sidebar-foot span,
small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.brand small {
  color: #a8b4c0;
}

.sidebar nav {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
  color: #dce6ef;
  font-weight: 700;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-foot a {
  color: #dce6ef;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

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

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions,
.button-row,
.filters,
.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row.tight {
  gap: 6px;
}

.content {
  padding: 28px;
  max-width: 1480px;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  align-items: center;
  gap: 36px;
  padding: 48px;
}

.login-copy {
  max-width: 680px;
}

.login-copy h1 {
  margin: 18px 0 12px;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.95;
}

.login-copy p {
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.mini-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.mini-metrics span {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 750;
}

.login-card,
.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 28px;
}

.login-card h2,
.panel h2 {
  margin: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

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

textarea {
  min-height: 90px;
  resize: vertical;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 790;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover,
button:hover {
  border-color: #bbc6d2;
}

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

.button.quiet {
  background: transparent;
}

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

.button.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

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

.stat-card {
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1.1;
}

.stat-card.green {
  background: var(--green-soft);
}

.stat-card.amber {
  background: var(--amber-soft);
}

.stat-card.blue {
  background: var(--blue-soft);
}

.grid {
  display: grid;
  gap: 18px;
}

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

.panel {
  margin-bottom: 18px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head span {
  color: var(--muted);
}

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

.form-stack {
  display: grid;
  gap: 12px;
}

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

.filters input {
  width: 230px;
}

.filters select {
  width: 150px;
}

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

.table-wrap.narrow {
  max-width: 760px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td strong {
  display: block;
  margin-bottom: 3px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.status-active,
.status-current,
.status-done,
.status-enabled {
  background: var(--green-soft);
  color: var(--green);
}

.status-trial,
.status-pending,
.status-in-progress,
.status-paused,
.status-comped {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-deleted,
.status-suspended,
.status-overdue,
.status-cancelled,
.status-blocked,
.status-disabled,
.status-inactive {
  background: var(--red-soft);
  color: var(--red);
}

.flash {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 7px;
  font-weight: 780;
}

.flash.ok {
  background: var(--green-soft);
  color: var(--green);
}

.flash.error {
  background: var(--red-soft);
  color: var(--red);
}

.detail-list {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 790;
}

.detail-list dd {
  margin: 0;
}

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

.module-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.module-toggle input {
  width: auto;
  margin-top: 3px;
}

.action-details summary {
  list-style: none;
}

.action-details summary::-webkit-details-marker {
  display: none;
}

.action-details[open] {
  min-width: 260px;
}

.action-details[open] summary {
  margin-bottom: 10px;
}

.danger-panel {
  border-color: #fac5bd;
  background: #fffaf8;
}

@media (max-width: 1100px) {
  .app-shell,
  .login-layout,
  .grid.two {
    grid-template-columns: 1fr;
  }

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

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

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

@media (max-width: 720px) {
  .content,
  .topbar,
  .login-layout {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar nav,
  .stat-grid,
  .form-grid,
  .module-grid,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select,
  .button,
  button {
    width: 100%;
  }
}
