:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-muted: #f1f3f4;
  --bg-accent: #e8f0fe;
  --text: #202124;
  --text-muted: #5f6368;
  --text-dim: #80868b;
  --line: #dadce0;
  --line-strong: #bdc1c6;
  --accent: #1a73e8;
  --success: #188038;
  --warning: #f29900;
  --danger: #d93025;
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.1), 0 1px 3px rgba(60, 64, 67, 0.08);
  --shadow-md: 0 1px 3px rgba(60, 64, 67, 0.16), 0 4px 8px rgba(60, 64, 67, 0.08);
  --font-body: "Roboto", "Google Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.app-body {
  overflow: hidden;
}

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

a:hover {
  text-decoration: underline;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

h1,
h2,
h3,
p {
  margin: 0;
}

strong {
  font-weight: 500;
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 252px;
  min-width: 252px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sidebar-kicker,
.eyebrow,
.page-kicker,
.tenant-label,
.section-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 2px 0;
  padding: 10px 14px;
  border-radius: 0 24px 24px 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--bg-muted);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--bg-accent);
  color: var(--accent);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
}

.tenant-card {
  display: grid;
  gap: 2px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tenant-card span:last-child,
.app-user span,
.page-summary,
.muted,
.form-message {
  color: var(--text-muted);
}

.text-button,
.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.text-button {
  padding: 8px 12px;
  background: transparent;
  color: var(--text-muted);
}

.text-button:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-bar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 0 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.app-bar-toggle {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.app-bar-toggle:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.app-bar-toggle svg {
  width: 18px;
  height: 18px;
}

.app-bar-title {
  display: grid;
  gap: 2px;
}

.app-bar-title h2 {
  font-size: 16px;
  font-weight: 500;
}

.app-bar-spacer {
  flex: 1;
}

.app-pill {
  padding: 6px 10px;
  background: var(--bg-accent);
  border: 1px solid #c6dafc;
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.app-user {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: right;
}

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

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
}

.page-header {
  margin-bottom: 20px;
}

.page-summary {
  max-width: 760px;
  font-size: 13px;
}

.metrics-grid,
.panel-grid,
.detail-grid,
.form-grid {
  display: grid;
  gap: 16px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric-card,
.panel,
.login-panel,
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.metric-card span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 28px;
  line-height: 1.1;
}

.metric-card.wide {
  grid-column: span 2;
}

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

.panel {
  padding: 18px;
}

.panel-header,
.page-actions,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header {
  margin-bottom: 14px;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 500;
}

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

.detail-grid div {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.detail-grid dt {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

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

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

.data-table th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody tr:hover {
  background: #fafbfd;
}

.status,
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}

.table-link {
  font-weight: 500;
}

.page-actions {
  margin-bottom: 16px;
}

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

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

.stack,
label {
  display: grid;
  gap: 6px;
}

label {
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(26, 115, 232, 0.2);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

.actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  padding: 9px 14px;
}

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

.primary-button:hover {
  background: #1765cc;
}

.secondary-button {
  background: var(--bg-card);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover {
  background: var(--bg-muted);
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
}

.error-panel {
  margin-bottom: 16px;
  border-color: #f3c7c3;
  background: #fce8e6;
}

.error-panel strong,
.error-panel p {
  color: var(--danger);
}

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

.login-panel,
.hero-card {
  border-radius: 0;
  box-shadow: none;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 56px;
  border-right: 1px solid var(--line);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-panel h1 {
  margin-bottom: 12px;
  font-size: 28px;
  font-weight: 400;
}

.lede {
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.login-side {
  padding: 40px;
  background:
    linear-gradient(180deg, rgba(232, 240, 254, 0.8) 0%, rgba(248, 249, 250, 0.4) 48%, rgba(255, 255, 255, 0.9) 100%),
    var(--bg);
}

.hero-card {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px;
  border: 1px solid #d2e3fc;
  background: rgba(255, 255, 255, 0.88);
}

.hero-card h2 {
  margin-bottom: 18px;
  font-size: 26px;
  font-weight: 400;
  line-height: 1.28;
}

.bullet-list {
  display: grid;
  gap: 14px;
}

.bullet-row {
  display: grid;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(218, 220, 224, 0.8);
}

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

.sidebar-overlay {
  display: none;
}

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

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

@media (max-width: 960px) {
  body.app-body {
    overflow: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(32, 33, 36, 0.2);
    z-index: 8;
  }

  .sidebar-overlay.is-open {
    display: block;
  }

  .app-user {
    display: none;
  }

  .main-content,
  .login-panel,
  .login-side {
    padding: 20px;
  }

  .detail-grid,
  .form-grid,
  .login-shell,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric-card.wide {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .app-bar {
    padding-right: 12px;
  }

  .main-content {
    padding: 18px 14px 28px;
  }

  .panel,
  .metric-card,
  .hero-card {
    padding: 14px;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .actions,
  .button-row {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    justify-content: center;
  }
}
