:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-muted: #eef3f6;
  --text: #17212b;
  --muted: #647381;
  --border: #d8e1e7;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --accent: #f9735b;
  --warning: #f6b73c;
  --success: #15803d;
  --danger: #c24135;
  --shadow: 0 16px 40px rgba(23, 33, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

a:hover {
  color: var(--primary-strong);
}

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

.auth-shell {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(360px, 1fr);
  min-height: 100vh;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  color: #f8fafc;
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.96), rgba(23, 33, 43, 0.98)),
    radial-gradient(circle at 20% 20%, rgba(246, 183, 60, 0.26), transparent 30%);
}

.auth-brand__top,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup img,
.auth-brand__top img {
  width: 44px;
  height: 44px;
}

.brand-name {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.brand-company {
  display: block;
  color: rgba(248, 250, 252, 0.72);
  font-size: 12px;
}

.brand-lockup .brand-company {
  color: var(--muted);
}

.auth-brand__top .brand-company {
  color: rgba(248, 250, 252, 0.72);
}

.auth-brand__content {
  max-width: 520px;
}

.auth-brand h1 {
  margin: 0 0 18px;
  max-width: 520px;
  font-size: 40px;
  line-height: 1.08;
}

.auth-brand p {
  margin: 0;
  color: rgba(248, 250, 252, 0.78);
  font-size: 17px;
}

.auth-snapshot {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 34px;
}

.snapshot-item {
  border: 1px solid rgba(248, 250, 252, 0.16);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(248, 250, 252, 0.08);
}

.snapshot-item span {
  display: block;
  color: rgba(248, 250, 252, 0.66);
  font-size: 12px;
}

.snapshot-item strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--surface);
}

.auth-card {
  width: min(100%, 520px);
}

.auth-card h2,
.page-title h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.auth-card__header,
.page-title {
  margin-bottom: 24px;
}

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

.form-grid {
  display: grid;
  gap: 16px;
}

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

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.required {
  color: var(--accent);
}

.input-wrap {
  position: relative;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.form-field textarea {
  min-height: 94px;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.field-error {
  color: var(--danger);
  font-size: 12px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
  background: var(--surface-muted);
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

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

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

.btn-secondary {
  color: var(--text);
  border-color: var(--border);
  background: #fff;
}

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

.alert {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  background: #fff;
}

.alert-success {
  border-left-color: var(--success);
}

.alert-error {
  border-left-color: var(--danger);
}

.alert-warning {
  border-left-color: var(--warning);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  background: #fff;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
  background: #eaf6f2;
}

.nav-icon {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.72;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.tenant-name {
  display: block;
  font-weight: 800;
}

.tenant-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 28px;
}

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

.panel,
.kpi-card,
.company-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px;
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

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

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

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

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.status.ok::before {
  background: var(--success);
}

.status.warn::before {
  background: var(--warning);
}

.status.danger::before {
  background: var(--danger);
}

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

.company-card {
  padding: 18px;
}

.company-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.meta-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  background: #fff;
}

.module-strip {
  display: grid;
  gap: 10px;
}

.module-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

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

@media (max-width: 980px) {
  .auth-shell,
  .app-shell,
  .dashboard-grid,
  .company-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 360px;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

@media (max-width: 640px) {
  .auth-brand,
  .auth-panel,
  .content,
  .topbar {
    padding: 20px;
  }

  .auth-brand h1 {
    font-size: 30px;
  }

  .auth-snapshot,
  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }
}
