:root {
  color-scheme: light;
  --navy: #172365;
  --blue: #3448c6;
  --primary: var(--blue);
  --ink: #17213b;
  --muted: #58647f;
  --bg: #f4f6fc;
  --surface: #fff;
  --line: #dce2ef;
  --border: var(--line);
  --soft-blue: #edf0ff;
  --success: #116048;
  --danger: #9b2945;
  --focus: #6685ff;
  --radius: 16px;
  --shadow: 0 12px 34px rgba(28, 44, 99, .07);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3.4vw, 2.35rem); line-height: 1.17; letter-spacing: -.032em; }
h2 { font-size: 1.28rem; line-height: 1.28; letter-spacing: -.018em; }
h3 { font-size: 1.08rem; line-height: 1.35; }
a { color: var(--blue); text-underline-offset: 3px; }
img, svg, audio, video { max-width: 100%; }
input, select, textarea, button { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.icon { display: inline-block; flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.sr-only, .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link { position: fixed; z-index: 100; top: .75rem; left: .75rem; transform: translateY(-160%); border-radius: 10px; padding: 10px 14px; background: white; }
.skip-link:focus-visible { transform: none; }

.btn, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 44px;
  padding: .57rem .88rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease;
}
.btn:not(:disabled):hover, .icon-button:not(:disabled):hover { background: #f0f3fd; border-color: #c5d1ef; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:not(:disabled):hover { background: #2638aa; border-color: #2638aa; }
.btn-secondary, .btn-quiet { color: var(--navy); }
.btn-danger { color: var(--danger); border-color: #efc9d3; background: #fff6f8; }
.btn-danger:not(:disabled):hover { background: #fce9ee; border-color: #e7a3b5; }
.icon-button { width: 44px; padding: 0; flex: none; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 1.2rem; box-shadow: 0 2px 5px rgba(34, 50, 108, .03); }
.empty { padding: 1.8rem 1.2rem; text-align: center; color: var(--muted); }
.empty h1, .empty h2, .empty h3 { color: var(--ink); }
.empty p { max-width: 42ch; margin: .55rem auto 0; }
.empty .btn { margin-top: 1rem; }
.empty > .icon { margin-bottom: .75rem; color: var(--blue); }
.page-title { min-width: 0; }
.field { display: grid; min-width: 0; gap: .42rem; color: var(--ink); font-weight: 600; }
.field small { font-size: .82rem; font-weight: 400; color: var(--muted); }
.field input:not([type=checkbox], [type=radio], [type=file]), .field select, .field textarea, .context-picker select {
  width: 100%;
  min-height: 46px;
  padding: .55rem .75rem;
  border: 1px solid #bcc8e1;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 400;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #737e98; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.form-error { border: 1px solid #f0c9d3; border-radius: 10px; padding: .75rem; background: #fff4f7; color: var(--danger); font-size: .93rem; font-weight: 500; }
.form-success { border-color: #aed8c8; background: #eefaf5; color: var(--success); }

.boot-state { display: grid; justify-items: center; align-content: center; min-height: 100svh; gap: 1rem; padding: 1.25rem; }
.boot-state img { border-radius: 14px; }
.loading-state { display: flex; justify-content: center; align-items: center; gap: .7rem; min-height: 180px; color: var(--muted); }
.loading-ring { width: 21px; height: 21px; border: 2px solid #d3dbf7; border-top-color: var(--blue); border-radius: 50%; animation: loading-spin .75s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.notices { position: fixed; right: clamp(12px, 4vw, 28px); bottom: 20px; display: grid; gap: .45rem; width: min(410px, calc(100vw - 24px)); z-index: 70; pointer-events: none; }
.notice { padding: .85rem 1rem; border-radius: 12px; background: #133c32; color: #fff; font-weight: 550; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.notice-error { background: #7d233a; }

.brand { display: inline-flex; align-items: center; gap: .7rem; color: inherit; font-size: 1.23rem; font-weight: 850; line-height: 1.08; letter-spacing: .018em; }
.brand img { display: block; width: 44px; height: 44px; object-fit: contain; border-radius: 12px; background: white; }
.brand small { display: block; margin-top: .25rem; font-size: .63rem; letter-spacing: .13em; font-weight: 700; }
.auth-layout { display: grid; grid-template-columns: minmax(330px, .82fr) minmax(0, 1fr); min-height: 100svh; }
.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(1.4rem, 4vh, 2.8rem);
  padding: clamp(1.75rem, 4.5vw, 4rem);
  color: white;
  background: radial-gradient(ellipse at 70% 54%, #3153a9 0%, transparent 63%), linear-gradient(153deg, #0b1532 4%, #182d65 83%);
}
.auth-visual { width: min(100%, 320px, 38vh); margin-inline: auto; }
.auth-brand-copy { max-width: 30rem; }
.auth-brand-copy p { font-size: clamp(2rem, 4vw, 4.3rem); line-height: 1.04; font-weight: 780; letter-spacing: -.055em; }
.auth-brand-copy span { display: block; margin-top: 1rem; color: #e2e7ff; font-size: clamp(1rem, 1.4vw, 1.18rem); }
.auth-main { display: grid; place-items: center; padding: clamp(1.25rem, 5vw, 4.5rem); background: radial-gradient(ellipse at 100% 0%, #e7efff, #f7f9ff 70%); }
.auth-main:focus, .main-content:focus { outline: none; }
.auth-card {
  width: min(100%, 490px);
  padding: clamp(1.35rem, 3.4vw, 2.5rem);
  border: 1px solid #dce4f6;
  border-radius: 22px;
  background: white;
  box-shadow: 0 18px 56px rgb(22 40 95 / 9%);
}
.auth-return { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; margin-bottom: .45rem; color: var(--navy); font-size: .9rem; font-weight: 650; text-decoration: none; }
.auth-return:hover { text-decoration: underline; }
.auth-card > .muted { margin: .6rem 0 1.7rem; }
.auth-card > .form-error { margin-top: 1.3rem; }
.auth-mobile-brand { display: none; }
.auth-form { display: grid; gap: 1rem; margin-top: 1.35rem; }
.auth-form .btn { min-height: 50px; margin-top: .3rem; }
.auth-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: .65rem; color: var(--navy); font-weight: 650; }
.auth-role-choices { display: grid; gap: 14px; margin-top: 1.5rem; }
.auth-role-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 108px;
  padding: 18px 16px;
  border: 1px solid #d8e2f4;
  border-radius: 16px;
  background: linear-gradient(125deg, #fff, #f5f8ff);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 5px 14px #182b5905;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .18s;
}
.auth-role-choice:hover { border-color: #7699ed; background: #f0f5ff; box-shadow: 0 8px 20px #234b9b10; transform: translateY(-2px); }
.auth-role-icon { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid #dbe5fb; border-radius: 14px; background: linear-gradient(145deg, #fff, #e5edff); color: #2956c9; box-shadow: 0 5px 10px #214d9c0c; }
.auth-role-choice strong { display: block; color: #183366; font-size: 1rem; font-weight: 750; }
.auth-role-choice small { display: block; margin-top: 4px; color: var(--muted); font-size: .83rem; line-height: 1.45; }
.auth-role-choice > .icon { color: #5271ae; }
.auth-create-account { display: grid; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid #e1e7f2; }
.auth-create-account p { color: var(--muted); font-size: .86rem; }
.auth-create-link { width: 100%; min-height: 48px; color: #2455c9; border-color: #c9d9fa; background: #f1f5ff; }
.auth-create-link.btn-primary { color: white; background: var(--blue); border-color: var(--blue); }
.auth-card > .auth-create-link { margin-top: 1.3rem; }
.auth-account-note { margin-top: 1.3rem; color: var(--muted); font-size: .85rem; line-height: 1.6; }
.auth-account-note a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 650; }
@media (max-width: 420px) {
  .auth-role-choice { grid-template-columns: auto minmax(0, 1fr); padding: 16px 13px; gap: 11px; }
  .auth-role-choice > .icon { display: none; }
  .auth-role-icon { width: 43px; height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-role-choice { transition: none; }
  .auth-role-choice:hover { transform: none; }
}
.password-field { position: relative; display: block; }
.password-field > input { padding-right: 3rem !important; }
.password-toggle { position: absolute; right: 1px; top: 1px; display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.password-toggle:hover { background: var(--soft-blue); }

.shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: .9rem; height: 100dvh; overflow-y: auto; padding: 1.15rem .8rem .9rem; background: #142053; color: #fff; }
.sidebar-brand, .topbar-brand { color: inherit; text-decoration: none; }
.sidebar-brand { padding: .12rem .52rem; }
.sidebar-company { display: grid; gap: .15rem; border: 1px solid #53649d; border-radius: 12px; padding: .6rem .7rem; background: #203065; overflow-wrap: anywhere; font-weight: 650; }
.sidebar-company small { color: #d0d9f5; font-size: .78rem; font-weight: 500; }
.sidebar-nav, .sidebar-footer, .drawer-nav, .drawer-footer { display: grid; gap: .25rem; }
.sidebar-footer { margin-top: auto; padding-top: .65rem; border-top: 1px solid #53649d; }
.shell-link { display: flex; min-width: 0; min-height: 44px; width: 100%; align-items: center; gap: .64rem; padding: .58rem .67rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: inherit; font-size: .9rem; font-weight: 600; text-align: left; text-decoration: none; }
.sidebar .shell-link { color: #e4eaff; }
.sidebar .shell-link:hover { background: #25356f; }
.sidebar .shell-link.is-active { color: #fff; background: #354a99; border-color: #566ab8; }
.sidebar .shell-link.is-active .icon { color: #d8e4ff; }
.context-picker { display: grid; gap: .3rem; margin-bottom: .25rem; font-size: .82rem; font-weight: 650; }
.context-picker select { min-width: 0; padding: .4rem .5rem; }
.sidebar .context-picker { color: #e5ebff; }
.shell-body { min-width: 0; }
.topbar { position: sticky; z-index: 10; top: 0; display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: .8rem; padding: .55rem clamp(1.1rem, 3vw, 2.5rem); border-bottom: 1px solid var(--line); background: #fff; }
.topbar-brand, .mobile-nav { display: none; }
.topbar-section { font-weight: 720; color: var(--navy); }
.topbar-user { display: inline-flex; align-items: center; gap: .55rem; }
.user-avatar { display: grid; width: 37px; height: 37px; flex: none; place-items: center; border: 1px solid #d1d8fb; border-radius: 50%; color: var(--navy); background: var(--soft-blue); font-size: .81rem; font-weight: 760; }
.user-label { font-size: .87rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.user-label small { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; }
.main-content { width: min(100%, 1440px); min-height: calc(100svh - 66px); margin-inline: auto; padding: clamp(1rem, 3vw, 2.6rem); }
.shell-error { max-width: 660px; margin: 1.5rem auto; }

#mobile-menu { width: min(100%, 480px); max-height: min(85dvh, 740px); margin: auto auto 0; padding: 1.1rem 1.1rem max(1.1rem, env(safe-area-inset-bottom)); border: 0; border-radius: 20px 20px 0 0; background: #fff; color: var(--ink); box-shadow: 0 -14px 50px rgba(23, 35, 101, .2); }
#mobile-menu::backdrop { background: rgba(18, 27, 61, .55); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.drawer-header p { margin-top: .18rem; }
.drawer-nav .shell-link:hover, .drawer-footer .shell-link:hover { background: #f5f6fd; }
.drawer-nav .shell-link.is-active { background: var(--soft-blue); color: var(--navy); border-color: #d8dfff; }
.drawer-footer { margin-top: .8rem; padding-top: .75rem; border-top: 1px solid var(--line); }

@media (max-width: 850px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .topbar-section { display: none; }
  .topbar { min-height: 59px; padding: .45rem max(1rem, env(safe-area-inset-right)) .45rem max(1rem, env(safe-area-inset-left)); }
  .topbar-brand { display: inline-flex; }
  .topbar-brand .brand { font-size: 1.02rem; gap: .46rem; }
  .topbar-brand .brand img { width: 37px; height: 37px; border-radius: 10px; }
  .topbar-brand .brand small { font-size: .55rem; }
  .mobile-nav { position: fixed; z-index: 20; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .15rem; padding: .25rem .28rem max(.32rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
  .mobile-nav .shell-link { flex-direction: column; align-items: center; justify-content: center; min-height: 52px; gap: .15rem; padding: .25rem .18rem; font-size: .69rem; line-height: 1.13; text-align: center; }
  .mobile-nav .shell-link.is-active { color: var(--navy); background: var(--soft-blue); }
  .mobile-nav .shell-link:not(.is-active):hover { background: #f3f5fd; }
  .main-content { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .notices { bottom: calc(71px + env(safe-area-inset-bottom)); }
}

@media (max-width: 680px) {
  .auth-layout { display: block; }
  .auth-brand { display: none; }
  .auth-main { min-height: 100svh; padding: max(1.6rem, env(safe-area-inset-top)) 1.35rem max(1.6rem, env(safe-area-inset-bottom)); }
  .auth-mobile-brand { display: block; margin-bottom: 2rem; color: var(--navy); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .user-label { display: none; }
  .card { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
