:root {
  --navy: #0f1c2e;
  --navy-deep: #0a1420;
  --accent: #1f6f5b;
  --accent-hover: #185a4a;
  --bg: #f3f5f8;
  --line: #e5eaf0;
  --muted: #6b7785;
  --sidebar-w: 264px;
  --card-shadow: 0 10px 28px rgba(15, 28, 46, 0.05);
}

body.app-body {
  background: var(--bg);
  min-height: 100vh;
  color: var(--navy);
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

#wrapper { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  position: sticky;
  top: 0;
  flex-shrink: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
}
.sidebar-nav {
  overflow-y: auto;
  flex: 1;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.brand-mark.lg { width: 3rem; height: 3rem; font-size: 1.25rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  padding: 0.62rem 0.85rem;
  border-radius: 0.55rem;
  margin-bottom: 0.12rem;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: rgba(31, 111, 91, 0.38); color: #fff; }
.sidebar-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

.main-area { min-width: 0; background: var(--bg); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.92) !important;
}
.content {
  max-width: none;
  width: 100%;
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-active-border-color: var(--accent-hover);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-kicker {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.page-title { margin: 0; font-size: 1.55rem; font-weight: 700; color: var(--navy); }
.page-subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.95rem; }

.toolbar-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--card-shadow);
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.stat-card .card-body { padding: 1rem 1.1rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.2; margin-top: 0.25rem; }
.stat-icon {
  width: 2.2rem; height: 2.2rem; border-radius: 0.55rem;
  display: inline-grid; place-items: center;
  background: rgba(31,111,91,0.12); color: var(--accent);
}

.company-tile {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 1rem;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.company-tile:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 28, 46, 0.08); }
.company-logo {
  width: 2.5rem; height: 2.5rem; border-radius: 0.65rem; object-fit: cover;
  background: #e8eef5; display: inline-grid; place-items: center; font-weight: 700; color: var(--navy);
}
.company-logo-lg {
  width: 4rem; height: 4rem; border-radius: 0.85rem; object-fit: cover;
  background: #e8eef5; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 1.4rem; color: var(--navy); flex-shrink: 0;
}
.company-logo-sm {
  width: 2.25rem; height: 2.25rem; border-radius: 0.55rem; object-fit: cover;
  background: #e8eef5; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; color: var(--navy); flex-shrink: 0;
}

.info-tile {
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
}
.info-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.info-value {
  font-weight: 600;
  color: var(--navy);
  word-break: break-word;
}
.mini-box { background: #f5f7fa; border-radius: 0.5rem; padding: 0.4rem 0.2rem; }

.card {
  border-color: var(--line);
  border-radius: 0.9rem;
  box-shadow: var(--card-shadow);
}
.letter-space { letter-spacing: 0.06em; }

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  border-bottom-width: 1px;
}
.table > :not(caption) > * > * { padding: 0.9rem 1rem; }
.table-link {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
}
.table-link:hover { color: var(--accent); text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}
.empty-state i { font-size: 2rem; color: #9aa7b5; margin-bottom: 0.75rem; display: block; }

.auth-panel { width: min(520px, 100%); background: #fff; }
.auth-visual {
  background:
    linear-gradient(160deg, rgba(15,28,46,0.88), rgba(31,111,91,0.75)),
    #0f1c2e;
}
.error-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}
.error-code {
  font-size: clamp(4.5rem, 10vw, 6.5rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--navy);
  margin: 0.15rem 0 0.4rem;
}
.error-visual-mark {
  text-align: center;
  color: rgba(255,255,255,0.92);
}
.error-visual-mark i {
  display: block;
  font-size: 4.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}
.error-visual-mark span {
  display: block;
  font-size: clamp(6rem, 14vw, 10rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 0.85;
  color: rgba(255,255,255,0.16);
}

.setting-option { cursor: pointer; }
.setting-option .setting-check {
  display: flex;
  align-items: flex-start;
  line-height: 1;
}
.setting-option .setting-check .form-check-input {
  float: none;
  margin: 0;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}
.setting-option .form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.platform-select-card {
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 1rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.platform-select-card.is-enabled {
  border-color: rgba(31, 111, 91, 0.45);
  box-shadow: 0 0 0 1px rgba(31, 111, 91, 0.12);
  background: linear-gradient(180deg, #fff 0%, #f4faf8 100%);
}

.coming-soon-card {
  background: linear-gradient(135deg, #fff 0%, #f3faf7 100%);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 2.5rem;
}
.coming-soon-tips {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.coming-soon-tips li { margin-bottom: 0.35rem; }

.account-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 220px;
}
.account-menu-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  text-align: left;
  min-width: 0;
}
.account-menu-name {
  font-weight: 600;
  font-size: 0.85rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-role {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}
.account-dropdown {
  min-width: 260px;
}
.account-dropdown-head {
  background: #f7f9fb;
}
.account-dropdown .dropdown-item {
  display: flex;
  align-items: center;
}
.account-dropdown .dropdown-item i {
  opacity: 0.75;
  width: 1.1rem;
}

.portal-type-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 1.1rem;
  background: #fff;
  box-shadow: var(--card-shadow);
  height: 100%;
}
.portal-type-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.65rem;
  display: inline-grid;
  place-items: center;
  background: rgba(31,111,91,0.12);
  color: var(--accent);
  flex-shrink: 0;
  font-size: 1.15rem;
}
.portal-saved-row {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  background: #fff;
}
.portal-login-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(31,111,91,0.1);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open { transform: none; }
}
