* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans KR", sans-serif;
  color: #0f172a;
  background: #f8fafc;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: #9fc4ea;
  border-bottom: 1px solid #7da9d6;
}

.brand {
  font-size: 20px;
  font-weight: 700;
}

.topmenu {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topmenu a {
  text-decoration: none;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 10px;
  background: transparent;
}

.topmenu a.active {
  background: #e2effb;
  font-weight: 700;
}

.userbox {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 13px;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.userbox .role {
  color: #334155;
  white-space: nowrap;
}

.userbox a {
  color: #0f172a;
  text-decoration: none;
  font-weight: 700;
}

.lang-links {
  display: inline-flex;
  gap: 6px;
}

.lang-links a {
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #7da9d6;
  background: #dcecff;
  color: #0f172a;
  font-weight: 700;
}

.lang-links a.active {
  background: #0f172a;
  color: #f8fafc;
}

/* Role preview switcher select - visible only to super_admin */
.view-switcher-form {
  display: inline-flex;
  align-items: center;
}

.view-switcher-select {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid #5a8fcc;
  background: #dceeff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  min-width: 140px;
}

.userbox-name {
  white-space: nowrap;
  flex-shrink: 0;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 68px);
}

.sidebar {
  border-right: 1px solid #dbe2ea;
  background: #ffffff;
  padding: 16px;
}

.sidebar h3 {
  margin: 4px 0 14px;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li + li {
  margin-top: 6px;
}

.sidebar a {
  display: block;
  text-decoration: none;
  color: #1f2937;
  background: #f1f5f9;
  padding: 9px 10px;
  border-radius: 9px;
}

.sidebar a.active {
  background: #dbeafe;
  color: #1e3a8a;
  font-weight: 700;
}

.trial-box {
  margin-top: 18px;
  padding: 10px;
  border-radius: 10px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  font-size: 13px;
}

.content {
  padding: 18px;
}

.demo-banner {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #d5e3fa;
  background: #eef4ff;
}

.demo-banner.active {
  border-color: #c8d9fb;
  background: #e9f2ff;
}

.demo-banner.expired {
  border-color: #fecaca;
  background: #fef2f2;
}

.demo-banner-title {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.demo-banner-text {
  font-size: 13px;
  color: #374151;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
}

.card-title {
  font-size: 13px;
  color: #475569;
}

.card-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
}

.panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.device-form {
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  gap: 8px;
  align-items: center;
}

.device-form input {
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.device-form button {
  border: 0;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: 10px;
  text-align: left;
}

thead th {
  background: #eff6ff;
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #bcd6f2 0%, #eaf2fb 60%, #ffffff 100%);
}

.login-wrap {
  width: min(420px, 92vw);
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #dbe2ea;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
  padding: 20px;
}

.login-wrap h1 {
  margin: 0 0 8px;
}

.sub {
  margin: 0 0 16px;
  color: #475569;
}

.alert {
  margin-bottom: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form input {
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.login-form select {
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.row-inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.row-inline-form select {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.row-inline-form button {
  border: 0;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.login-form button {
  border: 0;
  border-radius: 9px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
}

.login-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  text-decoration: none;
  font-weight: 700;
  padding: 10px;
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: #475569;
  display: grid;
  gap: 4px;
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #dbe2ea;
  }
  .device-form {
    grid-template-columns: 1fr;
  }
}

.row-inline-form input {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-width: 120px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #334155;
}

.form-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #475569;
}

.audit-payload {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 460px;
}
