:root {
  --ink: #14212b;
  --muted: #64727d;
  --paper: #f4f7f8;
  --surface: #ffffff;
  --line: #d9e1e5;
  --deep: #172933;
  --deep-soft: #223b46;
  --teal: #087f78;
  --teal-soft: #e2f4f1;
  --amber: #ad6a00;
  --amber-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 12px 34px rgba(20, 33, 43, 0.1);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, "Malgun Gothic", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.1fr);
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  color: #fff;
  background: var(--deep);
}

.brand-lockup {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  color: var(--deep);
  background: #e6f5f2;
  font-weight: 800;
}

.login-brand h1,
.brand-lockup strong {
  margin: 0;
}

.login-brand h1 {
  max-width: 520px;
  font-size: 42px;
  line-height: 1.2;
}

.login-brand p {
  max-width: 480px;
  color: #bdd1d7;
  line-height: 1.7;
}

.login-area {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-form {
  width: min(420px, 100%);
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h2,
h3,
p {
  margin-top: 0;
}

.login-form h2 {
  margin: 10px 0 8px;
  font-size: 34px;
}

.muted {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
}

.field + .field {
  margin-top: 16px;
}

.field span {
  color: #41515c;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #fff;
}

input,
select {
  height: 44px;
}

textarea {
  min-height: 104px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 120, 0.14);
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
}

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

.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.danger {
  color: var(--danger);
  border-color: #f3c6c2;
  background: #fff;
}

.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.login-form .primary {
  width: 100%;
  margin-top: 24px;
}

.form-error {
  min-height: 21px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
}

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

.sidebar {
  padding: 24px 16px;
  color: #e5eef0;
  background: var(--deep);
}

.sidebar .brand-lockup {
  padding: 0 8px 22px;
}

.sidebar .brand-mark {
  width: 44px;
  height: 44px;
}

.nav-section {
  margin: 24px 8px 8px;
  color: #8fb2ba;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-button {
  width: 100%;
  margin: 3px 0;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #c9dade;
  background: transparent;
  text-align: left;
}

.nav-button.active {
  border-color: #385964;
  color: #fff;
  background: var(--deep-soft);
}

.workspace {
  min-width: 0;
  padding: 24px 30px;
}

.topbar,
.section-heading,
.toolbar,
.modal-actions,
.credential-line {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

.user-chip {
  min-width: 160px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.user-chip strong,
.user-chip small {
  display: block;
}

.user-chip small {
  margin-top: 3px;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-item {
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
}

.summary-item strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.section-heading {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.section-heading h3 {
  margin-bottom: 4px;
  font-size: 18px;
}

.compact-heading {
  padding: 0;
  border-bottom: 0;
}

.compact-heading h4 {
  margin: 0 0 6px;
  font-size: 18px;
}

.toolbar {
  gap: 10px;
  padding: 14px 20px;
  justify-content: flex-start;
}

.search {
  max-width: 320px;
}

.table-wrap {
  overflow-x: auto;
}

.site-admin-grid {
  display: grid;
  gap: 22px;
}

.site-form {
  margin: 0 20px 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.site-form .form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide-field {
  grid-column: span 2;
}

.site-form .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.master-grid {
  display: grid;
  gap: 18px;
}

.master-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 20px;
}

.master-form {
  margin-bottom: 0;
}

.master-table {
  margin: 0 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.master-table h4 {
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal .site-form {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

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

.site-bulk-form {
  display: grid;
  gap: 16px;
}

.bulk-help {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.bulk-help code {
  white-space: normal;
  line-height: 1.7;
  color: var(--muted);
}

.bulk-paste-area {
  min-height: 150px;
  font-family: Consolas, Monaco, monospace;
  line-height: 1.6;
  resize: vertical;
}

.bulk-preview {
  display: grid;
  gap: 10px;
}

.bulk-summary {
  color: var(--muted);
  font-weight: 700;
}

tr.has-error {
  background: #fff4f2;
}

.error-text {
  color: #b42318;
  font-weight: 800;
}

.ok-text {
  color: #087443;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 13px 16px;
  border-top: 1px solid #edf1f2;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #fafcfc;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 700;
}

.badge.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.empty {
  padding: 46px 20px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(14, 26, 34, 0.48);
}

.modal {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(780px, 100%);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
  background: #f6f9fa;
}

.modal-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.modal-grid .field + .field {
  margin-top: 0;
}

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

.modal-actions {
  margin-top: 22px;
  justify-content: flex-end;
}

.credential-box {
  padding: 14px;
  border: 1px solid #cce5e1;
  border-radius: 6px;
  background: #f3fbfa;
}

.credential-line {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #d6ebe8;
}

.credential-line code {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
}

.note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.readonly-box {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfc;
}

.readonly-box > strong,
.readonly-box > p {
  display: block;
  margin: 0;
  padding: 14px 16px 0;
}

.compact-readonly {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-readonly div {
  min-height: 70px;
}

.self-workspace {
  max-width: 1480px;
}

.self-section + .self-section {
  margin-top: 16px;
}

.readonly-grid {
  display: grid;
  gap: 0;
  margin: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.readonly-grid div {
  min-height: 84px;
  padding: 16px 18px;
  border-top: 1px solid #edf1f2;
}

.readonly-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.readonly-grid dd {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
}

.self-form {
  padding: 18px 20px;
}

.compact-form {
  border-bottom: 1px solid #edf1f2;
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

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

.form-grid .field + .field {
  margin-top: 0;
}

.form-actions {
  display: flex;
  margin-top: 18px;
  justify-content: flex-end;
}

.status-message {
  min-height: 20px;
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.status-message.error {
  color: var(--danger);
}

.compact-empty {
  padding: 26px 20px;
}

.profile-photo-editor {
  align-items: flex-start;
  display: grid;
  gap: 18px;
  grid-template-columns: 148px minmax(0, 1fr);
}

.profile-photo-preview {
  align-items: center;
  aspect-ratio: 3 / 4;
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-weight: 700;
  justify-content: center;
  overflow: hidden;
  width: 148px;
}

.profile-photo-preview img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.profile-photo-form {
  min-width: 0;
}

.profile-photo-form .form-actions {
  justify-content: flex-start;
}

@media (max-width: 900px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 230px;
    padding: 30px;
  }

  .login-brand h1 {
    font-size: 30px;
  }

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

  .sidebar {
    padding: 14px;
  }

  .sidebar .brand-lockup {
    padding-bottom: 10px;
  }

  .nav-section {
    display: none;
  }

  .nav-button {
    display: inline-block;
    width: auto;
    margin-right: 4px;
    padding: 9px 10px;
  }

  .site-form .form-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }

  .workspace {
    padding: 18px;
  }

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

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

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .modal-grid,
  .readonly-grid,
  .form-grid.two,
  .form-grid.three,
  .profile-photo-editor {
    grid-template-columns: 1fr;
  }

  .profile-photo-preview {
    width: 132px;
  }

  .full {
    grid-column: auto;
  }
}
