@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --ink: #1b2638;
  --muted: #778397;
  --line: #e8edf3;
  --surface: #fff;
  --canvas: #f5f7fb;
  --blue: #3267e9;
  --blue-dark: #2552c7;
  --blue-light: #edf3ff;
  --green: #16835d;
  --red: #bd3b46;
  --sidebar-width: 224px;
  --sidebar-collapsed-width: 64px;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-view { display: grid; min-height: 100vh; place-content: center; justify-items: center; padding: 22px 16px; }
.startup-view { display: grid; min-height: 100vh; align-content: center; justify-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.startup-view .brand-mark { width: 42px; height: 42px; font-size: 24px; }
.startup-view p { margin: 0; }
.auth-card { width: min(100%, 410px); padding: 30px 32px 27px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 55px #2437580c; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-family: Manrope, sans-serif; font-size: 16px; font-weight: 800; letter-spacing: -.5px; }
.brand-auth { margin-bottom: 26px; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; color: #fff; background: var(--blue); font-size: 19px; }
.brand-sub { display: block; margin-top: -3px; color: var(--muted); font: 600 9px "DM Sans", sans-serif; letter-spacing: 2px; }
.auth-card h1 { margin: 0 0 6px; font: 800 22px Manrope, sans-serif; letter-spacing: -.6px; }
.auth-setup-link { display: inline-block; margin-top: 12px; color: var(--blue); font-size: 11px; font-weight: 600; text-decoration: none; }
.auth-setup-link:hover { text-decoration: underline; }
.form-stack { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field label { color: #475469; font-size: 11px; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 37px; padding: 8px 10px; border: 1px solid #dce3ec; border-radius: 7px; outline: none; color: var(--ink); background: #fff; font-size: 13px; }
.field input:focus, .field select:focus { border-color: #82a3fb; box-shadow: 0 0 0 3px #3267e91a; }
.field-hint { color: var(--muted); font-size: 10px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; font-size: 12px; font-weight: 700; }
.primary-button { color: white; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { color: #42516a; border-color: var(--line); background: #fff; }
.secondary-button:hover { background: #f8faff; }
.form-stack > .primary-button { width: 100%; margin-top: 3px; }
.message { margin: 10px 0 0; padding: 8px 10px; border-radius: 6px; font-size: 11px; line-height: 1.45; }
.message-error { color: #9f2733; background: #fff0f1; }
.message-success { color: #146d4e; background: #eaf8f1; }

.app-view { min-height: 100vh; }
.sidebar { position: fixed; z-index: 5; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); flex-direction: column; padding: 15px 12px 12px; border-right: 1px solid var(--line); background: #fff; transition: width .2s ease; }
.sidebar-top { display: flex; min-height: 38px; align-items: center; justify-content: space-between; padding: 0 3px; }
.sidebar-top .brand { gap: 10px; }
.icon-button { display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 7px; color: #718099; background: transparent; font-size: 22px; }
.icon-button:hover { color: var(--ink); background: #f2f5fa; }
.main-nav { display: grid; gap: 3px; }
.nav-group-label { margin: 12px 9px 4px; color: #9aa5b4; font-size: 9px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; }
.nav-link, .logout-button { display: flex; width: 100%; min-height: 36px; align-items: center; gap: 9px; padding: 0 9px; border: 0; border-radius: 7px; color: #647187; background: transparent; text-align: left; text-decoration: none; font-size: 12px; font-weight: 600; }
.nav-link:hover, .logout-button:hover { color: var(--ink); background: #f6f8fb; }
.nav-link.active { color: var(--blue); background: var(--blue-light); }
.nav-icon { display: inline-grid; width: 18px; flex: 0 0 18px; place-items: center; font-size: 16px; font-weight: 500; }
.sidebar-bottom { display: grid; gap: 9px; margin-top: auto; padding: 10px 4px 0; border-top: 1px solid var(--line); }
.connection-indicator { display: flex; align-items: center; gap: 7px; padding: 0 6px; color: #8290a3; font-size: 10px; }
.connection-indicator > span:first-child { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #43bb88; box-shadow: 0 0 0 3px #e7f7ef; }
.logout-button { min-height: 34px; }
.main-column { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left .2s ease; }
.topbar { position: sticky; z-index: 3; top: 0; display: flex; height: 54px; align-items: center; justify-content: space-between; padding: 0 25px; border-bottom: 1px solid var(--line); background: #ffffffed; backdrop-filter: blur(10px); }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: #8a96a7; font-size: 11px; }
.breadcrumb strong { color: #354258; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-user-copy { display: grid; gap: 1px; text-align: right; }
.topbar-user-copy strong { font-size: 11px; }
.topbar-user-copy span { color: var(--muted); font-size: 9px; }
.avatar { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 50%; color: #3558a7; background: #eaf0ff; font-size: 11px; font-weight: 700; }
.page-content { width: min(100%, 1460px); margin: 0 auto; padding: 22px 26px 30px; outline: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-heading h1 { margin: 0; font: 800 22px Manrope, sans-serif; letter-spacing: -.6px; }
.eyebrow { margin: 0 0 5px !important; color: var(--blue) !important; font-size: 9px !important; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.stat-card { min-height: 88px; padding: 12px 14px; }
.stat-label { display: flex; align-items: center; justify-content: space-between; color: #738096; font-size: 10px; font-weight: 600; }
.stat-icon { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 7px; color: var(--blue); background: #edf3ff; font-size: 13px; }
.stat-value { margin-top: 7px; font: 800 21px Manrope, sans-serif; letter-spacing: -.5px; }
.panel { overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font: 700 13px Manrope, sans-serif; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 12px 15px; }
.welcome-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 112px; margin-bottom: 12px; padding: 16px 19px; border: 1px solid #dce8ff; border-radius: 10px; background: linear-gradient(112deg, #f0f5ff 0%, #f9fbff 70%, #fff 100%); }
.welcome-panel h2 { margin: 0 0 5px; font: 800 17px Manrope, sans-serif; letter-spacing: -.3px; }
.welcome-panel p { max-width: 620px; margin: 0; color: #718099; font-size: 11px; line-height: 1.45; }
.welcome-art { display: grid; width: 54px; height: 54px; flex: 0 0 54px; place-items: center; border: 1px solid #d9e5ff; border-radius: 16px; color: var(--blue); background: #fff; font-size: 25px; }
.empty-state { padding: 16px 5px; color: var(--muted); font-size: 11px; text-align: center; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 8px 11px; color: #8a95a5; background: #fbfcfe; font-size: 10px; font-weight: 700; letter-spacing: .3px; }
td { padding: 8px 11px; border-top: 1px solid #eff2f6; color: #455268; font-size: 11px; }
.user-cell { display: flex; align-items: center; gap: 7px; }
.user-cell .avatar { width: 26px; height: 26px; }
.user-cell strong { display: block; color: #303c50; font-size: 11px; }
.user-cell small { display: block; margin-top: 1px; color: #919cac; font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 30px; color: var(--green); background: #eaf8f1; font-size: 10px; font-weight: 700; }
.status-pill::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.status-pill.inactive { color: #818b9b; background: #f0f2f5; }
.table-action { min-height: 29px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; color: #536178; background: #fff; font-size: 10px; font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 7px; }
.role-grid { display: grid; gap: 10px; }
.role-card { padding: 13px 15px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.role-card-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.role-card-head h3 { margin: 0 0 3px; font: 700 12px Manrope, sans-serif; }
.role-card-head p { margin: 0; color: var(--muted); font-size: 10px; }
.permission-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.permission-item { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-height: 34px; padding: 3px 7px; border: 1px solid #edf0f4; border-radius: 6px; color: #536178; font-size: 10px; }
.permission-item select { width: 110px; min-width: 0; min-height: 26px; padding: 3px 5px; border: 1px solid #e1e6ee; border-radius: 5px; color: #455268; background: #fff; font-size: 10px; }
.permission-item strong { color: #8a95a5; font-size: 9px; font-weight: 600; text-align: right; }
.permission-item.locked { color: #9aa4b3; background: #fafbfc; }
.notice { margin-bottom: 12px; padding: 8px 10px; border: 1px solid #dce8ff; border-radius: 7px; color: #53698c; background: #f5f8ff; font-size: 10px; line-height: 1.45; }
.inline-form { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; align-items: end; gap: 8px; }
.inline-form .field input, .inline-form .field select { min-height: 35px; font-size: 11px; }
.table-placeholder { padding: 14px; color: var(--muted); font-size: 11px; text-align: center; }
.setup-view { padding-top: 24px; padding-bottom: 24px; }
.setup-card { width: min(100%, 560px); padding: 27px 30px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 18px 55px #2437580c; }
.setup-card .brand-auth { margin-bottom: 22px; }
.setup-card > .eyebrow { margin-bottom: 7px !important; }
.setup-card > h1 { margin: 0 0 6px; font: 800 22px Manrope, sans-serif; letter-spacing: -.6px; }
.setup-steps { display: grid; gap: 0; margin: 15px 0; padding: 0; list-style: none; }
.setup-steps li { display: grid; grid-template-columns: 27px 1fr auto; align-items: center; gap: 8px; min-height: 47px; border-bottom: 1px solid #eff2f6; }
.setup-steps li:last-child { border-bottom: 0; }
.setup-step-number { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid #e1e7ef; border-radius: 50%; color: #8491a3; background: #fff; font-size: 10px; font-weight: 700; }
.setup-steps li.complete .setup-step-number { color: #fff; border-color: #28a778; background: #28a778; }
.setup-steps li.attention .setup-step-number { color: #a16615; border-color: #eedcb8; background: #fff8e9; }
.setup-steps li.current .setup-step-number { color: var(--blue); border-color: #cddaff; background: var(--blue-light); }
.setup-steps strong { color: #39465a; font-size: 11px; }
.setup-step-status { color: #929dad; font-size: 9px; text-align: right; }
.setup-steps li.complete .setup-step-status { color: var(--green); }
.setup-steps li.attention .setup-step-status { color: #a16615; }
.setup-guidance:empty { display: none; }
.setup-instructions { padding: 3px 2px 0; color: #647187; font-size: 10px; line-height: 1.55; }
.setup-instructions h2, .admin-setup h2 { margin: 0 0 7px; color: #364258; font: 700 12px Manrope, sans-serif; }
.setup-instructions ol { display: grid; gap: 4px; margin: 0 0 6px; padding-left: 18px; }
.setup-instructions p { margin: 6px 0 0; }
.setup-instructions a, .setup-login-link { color: var(--blue); font-weight: 700; }
.setup-instructions code { padding: 2px 4px; border-radius: 4px; color: #42516a; background: #f1f4f8; font-size: 10px; }
.admin-setup { margin-top: 13px; padding-top: 14px; border-top: 1px solid var(--line); }
.setup-login-link { display: inline-block; margin-top: 11px; font-size: 11px; text-decoration: none; }
.setup-login-link:hover { text-decoration: underline; }

.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); padding-right: 9px; padding-left: 9px; }
.sidebar-collapsed .main-column { margin-left: var(--sidebar-collapsed-width); }
.sidebar-collapsed .brand-name, .sidebar-collapsed .nav-label, .sidebar-collapsed .nav-group-label, .sidebar-collapsed .connection-indicator { display: none; }
.sidebar-collapsed .sidebar-top { justify-content: center; }
.sidebar-collapsed .sidebar-top .brand { display: none; }
.sidebar-collapsed .collapse-button span { transform: rotate(180deg); }
.sidebar-collapsed .nav-link, .sidebar-collapsed .logout-button { justify-content: center; padding: 0; }
.sidebar-collapsed .nav-icon { flex-basis: auto; }

@media (max-width: 820px) {
  :root { --sidebar-collapsed-width: 58px; }
  .sidebar { width: var(--sidebar-collapsed-width); padding-right: 8px; padding-left: 8px; }
  .main-column { margin-left: var(--sidebar-collapsed-width); }
  .sidebar .brand-name, .sidebar .nav-label, .sidebar .nav-group-label, .sidebar .connection-indicator { display: none; }
  .sidebar .sidebar-top { justify-content: center; }
  .sidebar .sidebar-top .brand { display: none; }
  .sidebar .nav-link, .sidebar .logout-button { justify-content: center; padding: 0; }
  .sidebar .nav-icon { flex-basis: auto; }
  .sidebar-collapsed .sidebar { width: var(--sidebar-width); }
  .sidebar-collapsed .main-column { margin-left: var(--sidebar-width); }
  .sidebar-collapsed .brand-name, .sidebar-collapsed .nav-label, .sidebar-collapsed .nav-group-label, .sidebar-collapsed .connection-indicator { display: initial; }
  .sidebar-collapsed .sidebar-top { justify-content: space-between; }
  .sidebar-collapsed .sidebar-top .brand { display: inline-flex; }
  .sidebar-collapsed .nav-link, .sidebar-collapsed .logout-button { justify-content: flex-start; padding: 0 9px; }
  .sidebar-collapsed .nav-icon { flex-basis: 18px; }
  .sidebar-collapsed .collapse-button { position: absolute; right: 8px; top: 20px; }
  .page-content { padding: 19px 17px 27px; }
  .topbar { padding: 0 17px; }
  .stats-grid { gap: 8px; }
}
@media (max-width: 600px) {
  :root { --sidebar-width: 205px; --sidebar-collapsed-width: 52px; }
  .auth-card { padding: 25px 20px; }
  .setup-card { padding: 22px 18px; }
  .sidebar { width: var(--sidebar-collapsed-width); padding-right: 7px; padding-left: 7px; }
  .main-column { margin-left: var(--sidebar-collapsed-width); }
  .sidebar-collapsed .sidebar { width: var(--sidebar-width); }
  .sidebar-collapsed .main-column { margin-left: var(--sidebar-width); }
  .topbar { height: 48px; padding: 0 10px; }
  .breadcrumb { gap: 5px; font-size: 9px; }
  .topbar-user-copy { display: none; }
  .page-content { padding: 16px 10px 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .page-heading h1 { font-size: 20px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .stat-card { min-height: 72px; padding: 9px 10px; }
  .stat-value { margin-top: 5px; font-size: 18px; }
  .welcome-panel { min-height: auto; padding: 13px; }
  .welcome-art { width: 42px; height: 42px; flex-basis: 42px; border-radius: 12px; font-size: 19px; }
  .permission-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
}
