:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-muted: #64748b;
  --border: #e2e8f0;
  --primary: #1e3a5f;
  --primary-dark: #0f172a;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body.login-page {
  min-height: 100vh;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.brand-panel {
  flex: 1;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a0505 50%, #3b0a0a 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-panel .logo,
.mobile-logo .logo {
  display: block;
  object-fit: contain;
  background: transparent;
}

.brand-panel .logo-hero {
  width: min(560px, 88vw);
  max-width: 100%;
  height: auto;
  margin: 0 0 32px;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.mobile-logo .logo {
  width: 96px;
  height: auto;
  margin: 0 auto;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.brand-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 480px;
  width: 100%;
}

.brand-panel h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.2;
  text-align: center;
}

.brand-panel .lead {
  color: rgba(255,255,255,0.72);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0;
  max-width: 420px;
  text-align: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.chip {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.12);
  font-size: 12px;
  color: #fff;
}

.brand-footer {
  color: rgba(255,255,255,0.45);
  font-size: 14px;
  margin-top: 24px;
}

.login-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-inner {
  width: 100%;
  max-width: 440px;
}

.login-inner h2 {
  font-size: 1.75rem;
  margin: 0 0 6px;
  font-weight: 700;
}

.login-inner .subtitle {
  color: var(--ink-muted);
  margin: 0 0 20px;
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.card .hint {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.35;
  margin: 0 0 16px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0 12px;
  transition: border-color 0.15s;
}

.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 10px;
  font-size: 15px;
  background: transparent;
  color: var(--ink);
}

.field .helper {
  font-size: 10px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary:hover { background: #16304d; }
.btn-primary:disabled { opacity: 0.65; cursor: wait; }

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn-download svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-download:hover {
  background: #f8fafc;
  border-color: var(--primary);
}

.download-note {
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
  margin: 6px 0 0;
}

.notice {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.notice.error {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--danger);
}

.session-note {
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 16px;
}

.mobile-logo {
  display: none;
  justify-content: center;
  align-items: center;
  margin-bottom: 28px;
  padding-top: 8px;
}

.login-inner h2,
.login-inner .subtitle {
  text-align: left;
}

/* Portal */
.portal-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.portal-header .user {
  font-size: 13px;
  opacity: 0.85;
}

.portal-body {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .ok {
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline:hover { background: #f8fafc; }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

@media (max-width: 899px) {
  .layout { flex-direction: column; }
  .brand-panel { display: none; }
  .login-panel {
    min-height: 100vh;
    align-items: flex-start;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .mobile-logo { display: flex; }
  .login-inner h2,
  .login-inner .subtitle {
    text-align: center;
  }
}

.role-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}

.role-picker {
  width: min(440px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 20px;
}

.role-picker h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.role-picker-sub {
  margin: 0 0 14px;
  color: var(--ink-muted, #64748b);
  font-size: 0.85rem;
  line-height: 1.45;
}

.role-picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.role-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.role-picker-item:hover {
  border-color: var(--primary, #1e3a5f);
  background: #f8fafc;
}

.role-picker-assignment {
  font-size: 0.78rem;
  color: var(--ink-muted, #64748b);
}

.role-picker-cancel {
  width: 100%;
  justify-content: center;
}

