:root {
  color-scheme: light;
  --ink: #142233;
  --muted: #657489;
  --line: #dce5ee;
  --soft: #f4f8fb;
  --blue: #1d65d6;
  --blue-dark: #124ca8;
  --green: #0b8a63;
  --red: #c23838;
  --violet: #7656d8;
  --shadow: 0 20px 55px rgba(37, 65, 93, .12);
  font-family: Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: linear-gradient(180deg, #eef6ff 0, #f8fbfd 280px, #fff 100%); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.topbar {
  height: 74px; padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(167, 188, 211, .45); background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, #1b6fe8, #684bcc); color: #fff; font-weight: 900; letter-spacing: -.7px; box-shadow: 0 8px 22px rgba(37, 90, 197, .24); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .11em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.page-shell { width: min(1180px, calc(100% - 32px)); min-height: calc(100vh - 160px); margin: 0 auto; padding: 52px 0 72px; }
.notice { margin: 0 0 20px; padding: 14px 18px; border: 1px solid #bcd7fa; border-radius: 14px; background: #eaf4ff; color: #174f94; font-size: 14px; }
.notice.error { border-color: #f0b8b8; background: #fff0f0; color: #992f2f; }

.auth-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 34px; align-items: stretch; }
.auth-intro { padding: 54px 52px; border-radius: 30px; color: #fff; background: radial-gradient(circle at 90% 10%, rgba(142, 114, 255, .55), transparent 36%), linear-gradient(145deg, #123d77, #13243e 70%); box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 16px; color: #8fc6ff; font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.auth-intro h1 { margin: 0; max-width: 620px; font-size: clamp(32px, 4.2vw, 58px); line-height: 1.08; letter-spacing: -.055em; }
.auth-intro h1 span { color: #9ecbff; }
.auth-intro > p:not(.eyebrow) { max-width: 620px; margin: 24px 0 32px; color: #ccdaed; font-size: 16px; line-height: 1.8; }
.auth-points { display: grid; gap: 12px; }
.auth-points div { display: flex; align-items: center; gap: 11px; color: #e9f2ff; font-size: 14px; }
.auth-points b { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: rgba(112, 180, 255, .18); color: #9fd0ff; }

.card { border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.auth-card { padding: 30px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 26px; padding: 5px; border-radius: 14px; background: var(--soft); }
.tabs button { padding: 11px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; }
.tabs button.active { color: var(--blue); background: #fff; font-weight: 800; box-shadow: 0 4px 14px rgba(38, 77, 120, .09); }
.form-stack { display: grid; gap: 15px; }
.form-stack h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.035em; }
.form-stack .lead { margin: 0 0 6px; color: var(--muted); font-size: 13px; line-height: 1.6; }
label { display: grid; gap: 7px; color: #34465b; font-size: 12px; font-weight: 700; }
input, select { width: 100%; padding: 13px 14px; border: 1px solid #cfdbe7; border-radius: 11px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: #70a8ef; box-shadow: 0 0 0 3px rgba(55, 127, 220, .12); }
button.primary, a.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px; color: #fff; background: var(--blue); font-weight: 800; text-decoration: none; cursor: pointer; }
button.primary:hover, a.primary:hover { background: var(--blue-dark); }
button.primary:disabled { opacity: .55; cursor: wait; }
button.ghost { padding: 9px 14px; border: 1px solid var(--line); border-radius: 11px; color: #40526a; background: #fff; cursor: pointer; }
.fine-print { margin: 2px 0 0; color: #7c8999; font-size: 11px; line-height: 1.65; }

.dashboard-head { display: flex; justify-content: space-between; gap: 22px; align-items: flex-end; margin-bottom: 25px; }
.dashboard-head h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); letter-spacing: -.055em; }
.dashboard-head p { margin: 9px 0 0; color: var(--muted); }
.role-badge { padding: 8px 12px; border-radius: 999px; color: #19599f; background: #e7f2ff; font-size: 11px; font-weight: 900; }
.pending-card { padding: 36px; text-align: center; }
.pending-card .icon { width: 58px; height: 58px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; color: #9a6c13; background: #fff1c9; font-size: 26px; }
.pending-card h2 { margin: 0 0 10px; }
.pending-card p { margin: 0; color: var(--muted); line-height: 1.7; }

.module-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.module-card { padding: 19px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.module-card.disabled { opacity: .58; }
.module-card span { display: inline-grid; place-items: center; width: 33px; height: 33px; margin-bottom: 15px; border-radius: 11px; color: #fff; background: linear-gradient(145deg, var(--blue), var(--violet)); font-weight: 900; }
.module-card h3 { margin: 0 0 7px; font-size: 15px; }
.module-card p { min-height: 35px; margin: 0 0 16px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.module-card button { width: 100%; padding: 9px 10px; border: 1px solid #cfdceb; border-radius: 9px; color: var(--blue); background: #f8fbff; cursor: pointer; }
.module-card button:disabled { color: #8491a0; cursor: not-allowed; }

.admin-layout { display: grid; gap: 20px; }
.panel { padding: 25px; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.organization-card { margin-top: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: #fbfdff; }
.organization-title { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.organization-title h3 { margin: 0; font-size: 17px; }
.organization-title small { color: var(--muted); }
.status { padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 900; }
.status.active { color: #087255; background: #dff7ee; }
.status.pending_review { color: #8f650b; background: #fff2c9; }
.permission-matrix { overflow-x: auto; }
.permission-row { min-width: 700px; display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(var(--module-count), minmax(105px, 1fr)); align-items: center; border-top: 1px solid #e8eef4; }
.permission-row > div { min-height: 54px; padding: 10px; display: grid; place-items: center; text-align: center; font-size: 11px; }
.permission-row > div:first-child { place-items: center start; text-align: left; }
.permission-row.header { border-top: 0; color: #60738a; background: #f3f7fb; font-weight: 800; }
.permission-row.company { color: #173d68; background: #edf5ff; font-weight: 800; }
.user-cell strong, .user-cell small { display: block; }
.user-cell small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; }
.switch input { width: 1px; height: 1px; opacity: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e0; cursor: pointer; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(30, 50, 70, .2); transition: .2s; }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:disabled + i { opacity: .45; cursor: not-allowed; }
.inline-form { display: grid; grid-template-columns: 1.2fr .8fr auto; gap: 10px; align-items: end; }
.module-form { display: grid; grid-template-columns: .6fr 1fr 1.6fr 1.4fr .7fr auto; gap: 9px; align-items: end; }
.copy-result { margin-top: 12px; padding: 13px; border: 1px dashed #91b7e5; border-radius: 11px; background: #f2f8ff; overflow-wrap: anywhere; color: #245487; font-size: 12px; }

footer { padding: 24px max(16px, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 11px; line-height: 1.65; }
footer p { margin: 0 0 5px; }
footer a { color: var(--blue); }

@media (max-width: 940px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-intro { padding: 40px 34px; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .module-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .topbar { height: 66px; padding: 0 16px; }
  .brand small { display: none; }
  .page-shell { width: min(100% - 22px, 1180px); padding-top: 24px; }
  .auth-intro, .auth-card, .panel { padding: 24px 20px; border-radius: 20px; }
  .auth-intro h1 { font-size: 35px; }
  .dashboard-head { align-items: flex-start; flex-direction: column; }
  .module-grid { grid-template-columns: 1fr; }
  .inline-form, .module-form { grid-template-columns: 1fr; }
}
