:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  --page: #f0f1f6;
  --ink: #25263a;
  --muted: #858fa4;
  --line: #e8e9f0;
  --surface: #fff;
  --surface-soft: #f4f4f9;
  --surface-hover: #e9eaf1;
  --surface-selected: #fcfaff;
  --accent: #7839e5;
  --accent-hover: #6930cb;
  --olive: #7839e5;
  --shadow: rgb(37 38 58 / 6%);
  --button-gradient: linear-gradient(105deg, #2869f4 0%, #7838ef 55%, #d522df 100%);
  --table-line: #e8e9f0;
  --success-surface: #edf3e7;
  --success-ink: #526c38;
  --danger-surface: #fae9e7;
  --danger-ink: #b52f29;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #20232c;
  --ink: #fafaff;
  --muted: #c4c9d5;
  --line: #414653;
  --surface: #2a2e38;
  --surface-soft: #343a47;
  --surface-hover: #3b414e;
  --surface-selected: #332d41;
  --accent: #a477f0;
  --accent-hover: #9162df;
  --olive: #a477f0;
  --shadow: rgb(0 0 0 / 22%);
  --table-line: #414653;
  --success-surface: #303e31;
  --success-ink: #b5d6a4;
  --danger-surface: #4b3035;
  --danger-ink: #f0a29b;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--page); transition: background-color 420ms ease, color 420ms ease; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.login-card { width: min(calc(100% - 32px), 440px); margin: min(12vh, 110px) auto; padding: clamp(24px, 6vw, 42px); border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: 0 18px 50px var(--shadow); }
.brand-mark, .eyebrow { color: var(--olive); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.eyebrow-brand { color: var(--ink); transition: color 420ms ease; }
.login-card h1 { margin: 12px 0 8px; font-size: clamp(26px, 7vw, 34px); letter-spacing: -.04em; }
.muted { color: var(--muted); line-height: 1.5; }
.login-card form { margin-top: 24px; }
label { display: block; margin: 16px 0 7px; font-size: 14px; font-weight: 650; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgb(120 57 229 / 22%); outline-offset: 2px; }
.primary-button, .secondary-button { min-height: 42px; padding: 9px 16px; border: 0; border-radius: 11px; font-weight: 700; transition: background .15s, transform .15s; }
.primary-button { background: var(--button-gradient); color: #fff; }
.primary-button:hover { filter: brightness(1.06); }
.secondary-button { background: var(--surface-soft); color: var(--ink); }
.secondary-button:hover { background: var(--surface-hover); }
.danger-button { min-height: 42px; padding: 9px 16px; border: 0; border-radius: 11px; background: #b93832; color: #fff; font-weight: 700; }
.danger-button:hover { background: #982d28; }
.login-card .primary-button { width: 100%; margin-top: 18px; }
.error-text { min-height: 20px; color: #a33030; font-size: 14px; }

.crm-layout { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex: 0 0 260px; flex-direction: column; width: 260px; height: 100vh; padding: 26px 16px 18px; border-right: 1px solid var(--line); background: var(--surface); transition: background-color 420ms ease, border-color 420ms ease; }
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 30px 14px; }
.sidebar-brand { min-width: 0; color: var(--ink); font-size: 18px; font-weight: 850; letter-spacing: -.04em; text-decoration: none; }
.sidebar-brand span { color: var(--accent); }
.theme-toggle { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; padding: 0; border: 0; border-radius: 13px; background: var(--surface-soft); color: var(--ink); cursor: pointer; transition: background-color 420ms ease, color 420ms ease; }
.theme-toggle:disabled { cursor: wait; opacity: .7; }
.theme-icon { display: block; width: 23px; height: 23px; background: currentColor; -webkit-mask: url('/assets/change-theme.svg') center / contain no-repeat; mask: url('/assets/change-theme.svg') center / contain no-repeat; transition: transform 700ms cubic-bezier(.2,.75,.25,1); }
.sidebar-nav { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 13px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; font-weight: 620; }
.nav-link:hover { background: var(--surface-soft); color: var(--ink); }
.nav-link.active { background: var(--surface-selected); color: var(--accent); }
.nav-icon { display: grid; width: 22px; height: 22px; place-items: center; font-size: 19px; }
.sidebar-footer { display: grid; grid-template-columns: minmax(0, 1fr) 25px; gap: 8px; align-items: center; margin-top: auto; padding: 16px 7px 0; border-top: 1px solid var(--line); }
.identity-copy { min-width: 0; }
.identity-copy strong, .identity-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-copy strong { font-size: 13px; }
.identity-copy span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.logout-icon-button { display: grid; width: 25px; height: 25px; place-items: center; border: 0; border-radius: 8px; background: var(--danger-surface); color: var(--danger-ink); }
.logout-icon-button:hover { filter: brightness(.95); }
.logout-icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.workspace { width: min(100%, 1600px); min-width: 0; margin: 0 auto; padding: 34px clamp(18px, 4vw, 56px) 56px; }
.workspace-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.workspace-header h1 { margin: 5px 0 0; font-size: clamp(25px, 4vw, 34px); letter-spacing: -.04em; }
.menu-toggle { display: none; }
.notice { min-height: 24px; margin: 0 0 14px; color: var(--accent); font-size: 14px; }
.page-content { display: grid; gap: 22px; }
.panel { min-width: 0; padding: clamp(18px, 3vw, 30px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 26px var(--shadow); transition: background-color 420ms ease, border-color 420ms ease, color 420ms ease, box-shadow 420ms ease; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.section-heading .muted { margin: 0; font-size: 14px; }
.table-wrap { width: 100%; overflow-x: auto; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; }
.page-button { display: grid; min-width: 36px; height: 36px; padding: 0 9px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 650; }
.page-button:hover:not(:disabled) { background: var(--surface-soft); }
.page-button:disabled { cursor: default; opacity: .4; }
.page-button.current { border-color: var(--accent); background: var(--accent); color: #fff; }
.page-gap { padding: 0 2px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--table-line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.user-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 22px; }
.user-stat-card { display: grid; gap: 10px; min-height: 96px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, var(--surface), var(--surface-soft)); }
.user-stat-card span { color: var(--muted); font-size: 13px; line-height: 1.35; }
.user-stat-card strong { color: var(--ink); font-size: 26px; letter-spacing: -.04em; }
.users-table { min-width: 620px; table-layout: fixed; }
.users-table th:nth-child(1), .users-table td:nth-child(1) { width: 260px; }
.users-table th:nth-child(2), .users-table td:nth-child(2) { width: 150px; }
.users-table th:nth-child(3), .users-table td:nth-child(3) { width: 100px; }
.users-table th:nth-child(4), .users-table td:nth-child(4) { width: 130px; }
.users-table .user-name-cell { display: table-cell; }
.users-table .user-name-cell bdi { display: inline-block; max-width: calc(100% - 40px); overflow: hidden; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }
.users-table .user-username-cell bdi { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-icon-button { display: inline-grid; width: 30px; height: 30px; margin-right: 8px; padding: 6px; place-items: center; vertical-align: middle; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--accent); }
.profile-icon-button:hover { background: var(--surface-hover); }
.profile-icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.user-details-list { display: grid; gap: 0; margin: 14px 0 8px; }
.user-details-list > div { display: grid; grid-template-columns: minmax(125px, .8fr) minmax(0, 1.2fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--table-line); }
.user-details-list dt { color: var(--muted); font-size: 13px; }
.user-details-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 620; }
.learning-language-icons { display: flex; min-height: 30px; align-items: center; gap: 7px; }
.learning-language-icons.has-language-icons { justify-content: flex-start; }
.learning-language-slot { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-soft); }
.learning-language-slot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.partner-balance { margin: 8px 0 4px; color: var(--muted); }
.partner-balance strong { color: var(--ink); font-size: 24px; }
td select { min-width: 112px; min-height: 38px; padding: 6px 9px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; background: var(--success-surface); color: var(--success-ink); font-size: 12px; font-weight: 700; }
.status-pill.disabled { background: var(--danger-surface); color: var(--danger-ink); }
.account-create-form { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(180px, 1fr) minmax(150px, .8fr) auto; align-items: end; gap: 12px; margin: 18px 0 24px; }
.account-create-form label { margin-top: 0; }
.account-create-form button { min-height: 44px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.action-buttons button { min-height: 36px; padding: 7px 10px; font-size: 12px; white-space: nowrap; }
.history-table td { white-space: normal; min-width: 120px; }
.history-table td:first-child { min-width: 150px; white-space: nowrap; }
.history-table td:nth-child(2) { min-width: 110px; }
.history-table td:last-child { min-width: 140px; }
.footnote { margin: 16px 0 0; font-size: 12px; }

.modal { width: min(calc(100% - 28px), 500px); max-height: min(90vh, 760px); padding: clamp(20px, 5vw, 30px); overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 25px 90px rgb(0 0 0 / 25%); }
.login-card, input, select, .secondary-button, .page-button, .user-stat-card, .profile-icon-button, .modal { transition: background-color 420ms ease, border-color 420ms ease, color 420ms ease, box-shadow 420ms ease; }
.modal::backdrop { background: rgb(20 24 18 / 48%); backdrop-filter: blur(2px); }
.modal form { display: grid; gap: 4px; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal h2 { margin-bottom: 2px; font-size: 23px; }
.modal form > .muted { margin: 0 0 8px; font-size: 14px; }
.modal label { margin-top: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin: 18px 0 6px !important; cursor: pointer; }
.checkbox-row input { flex: 0 0 19px; width: 19px; min-height: 19px; height: 19px; margin: 0; accent-color: var(--olive); }
.checkbox-row span { font-weight: 650; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.modal-actions button { min-width: 112px; }
.compact-modal { width: min(calc(100% - 28px), 420px); }
.compact-modal .modal-actions { margin-top: 18px; }
.sidebar-backdrop { display: none; }

@media (max-width: 980px) {
  .sidebar { flex-basis: 228px; width: 228px; }
  .account-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-create-form button { grid-column: 1 / -1; }
  .user-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 30; left: 0; width: min(82vw, 300px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 16px 0 45px rgb(0 0 0 / 12%); }
  .sidebar-visible .sidebar { transform: translateX(0); }
  .sidebar-visible .sidebar-backdrop { position: fixed; z-index: 20; inset: 0; display: block; border: 0; background: rgb(15 20 13 / 45%); }
  .workspace { padding: 20px 14px 32px; }
  .workspace-header { gap: 12px; }
  .menu-toggle { display: grid; flex: 0 0 42px; gap: 4px; width: 42px; height: 42px; place-content: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .menu-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink); }
  .notice { margin-bottom: 10px; }
  .section-heading { align-items: flex-start; }
  .panel { border-radius: 15px; }
  .history-table { min-width: 740px; }
  .user-stats-grid { gap: 8px; }
  .user-stat-card { min-height: 86px; padding: 13px; }
  .user-stat-card strong { font-size: 23px; }
}
@media (max-width: 480px) {
  .account-create-form { grid-template-columns: 1fr; }
  .account-create-form button { grid-column: auto; width: 100%; }
  .section-heading > .secondary-button { flex: 0 0 auto; padding-inline: 11px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
  .user-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-stat-card span { font-size: 12px; }
  .user-details-list > div { grid-template-columns: 1fr; gap: 5px; }
  .user-details-list > .learning-language-detail { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
