@layer reset, base, layout, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body, h1, h2, h3, p, dl, dd { margin: 0; }
  button, input, select, textarea { font: inherit; }
  button, summary { cursor: pointer; }
  button:disabled { cursor: not-allowed; }
  a { color: inherit; }
}

@layer base {
  :root {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #152a43; background: #f4f7fb;
    font-synthesis: none; text-rendering: optimizeLegibility;
    --blue: #146bca; --blue-dark: #0956a8; --line: #dce5ef;
    --muted: #576b80; --paper: #fff; --radius: 16px;
  }
  body { min-width: 280px; font-size: 14px; line-height: 1.55; }
  h1, h2, h3 { color: #12263f; line-height: 1.2; letter-spacing: -.025em; }
  h1 { font-size: clamp(26px, 3vw, 36px); font-weight: 650; }
  h2 { font-size: 23px; font-weight: 650; }
  h3 { font-size: 16px; font-weight: 650; }
  :focus-visible { outline: 3px solid #1f78db; outline-offset: 3px; }
  button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
  input, select, textarea { min-width: 0; width: 100%; border: 1px solid #c7d5e3; background: #fff; color: #152a43; border-radius: 8px; padding: 10px 12px; min-height: 44px; }
  textarea { min-height: 88px; resize: vertical; }
  input:focus, select:focus, textarea:focus { outline: 2px solid #2d7bc9; outline-offset: 1px; }
  input[type=checkbox] { width: 18px; height: 18px; min-height: 18px; accent-color: var(--blue); }
  ::placeholder { color: #758698; }
  small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
  .subtle { color: var(--muted); }
  .eyebrow { color: #31638f; font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
  .brand { display: inline-flex; align-items: baseline; font-size: 27px; letter-spacing: -.06em; font-weight: 760; text-decoration: none; color: #152a43; line-height: 1; }
  .brand span { color: #1473d5; }
  .skip-link { position: fixed; left: 16px; top: -80px; background: #fff; padding: 12px; z-index: 20; border: 1px solid var(--blue); border-radius: 8px; }
  .skip-link:focus { top: 12px; }
  .initial-state { min-height: 100svh; display: grid; align-content: center; justify-items: center; gap: 22px; }
}

@layer layout {
  .workspace-header { height: 72px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 30px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
  .header-brand, .header-account { display: flex; align-items: center; gap: 18px; min-width: 0; }
  .workspace-tag { border-left: 1px solid var(--line); padding-left: 18px; color: var(--muted); font-size: 12px; white-space: nowrap; }
  .user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
  .workspace-layout { display: grid; grid-template-columns: 204px minmax(0, 1fr); min-height: calc(100svh - 72px); }
  .workspace-sidebar { padding: 28px 14px; border-right: 1px solid var(--line); background: #fbfcfe; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
  .workspace-nav { display: flex; flex-direction: column; gap: 6px; }
  .nav-link { min-height: 46px; padding: 11px 16px; color: #476179; background: transparent; border: 1px solid transparent; border-radius: 10px; text-align: left; font-size: 13px; font-weight: 600; transition: background .18s, color .18s; }
  .nav-link:hover { background: #eaf1f9; color: #0c56a0; }
  .nav-link.active { color: #095aaf; background: #e3effc; border-color: #d0e2f7; }
  .sidebar-note { padding: 0 13px; font-size: 11px; color: #71849a; display: flex; align-items: center; gap: 8px; }
  .status-dot { width: 6px; height: 6px; border-radius: 50%; background: #4797d9; }
  .workspace-main { min-width: 0; max-width: 1400px; width: 100%; padding: 30px clamp(20px, 3.5vw, 50px) 48px; margin-inline: auto; }
  .page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
  .page-heading .eyebrow { margin-bottom: 7px; }
  .today-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
  .content-stack { display: flex; flex-direction: column; gap: 20px; }
  .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .section-heading p { color: var(--muted); font-size: 13px; margin-top: 7px; }
  .section-heading h2 { font-size: 20px; }
  .metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
  .detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
  .link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 16px; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .form-wide { grid-column: 1/-1; }
  .form-stack { display: flex; flex-direction: column; gap: 17px; }
  .field { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 600; }
  .button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .action-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
  .action-panel h3 { margin-bottom: 6px; }
  .action-panel .button-row { flex-shrink: 0; }
}

@layer components {
  .button { min-height: 44px; display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 10px 17px; border: 1px solid var(--blue); border-radius: 8px; background: var(--blue); color: #fff; text-decoration: none; font-weight: 650; font-size: 13px; line-height: 1.3; transition: background .18s, border-color .18s, box-shadow .18s; white-space: nowrap; }
  .button:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); box-shadow: 0 3px 9px #07529c18; }
  .button.secondary { background: #fff; color: #145c9e; border-color: #c5d7e8; }
  .button.secondary:hover:not(:disabled) { background: #edf5ff; border-color: #87b5df; }
  .button.small { padding: 9px 12px; font-size: 12px; }
  .button.full { width: 100%; }
  .button:disabled { opacity: .5; box-shadow: none; }
  .panel, .metric-card, .link-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 14px #13284403; }
  .panel { padding: 22px; }
  .panel > h3 { margin-bottom: 20px; }
  .metric-card { padding: 18px 20px; }
  .metric-card p { font-size: 12px; color: var(--muted); }
  .metric-card strong { display: block; font-size: 30px; line-height: 1.2; margin-top: 9px; font-weight: 650; letter-spacing: -.035em; }
  .welcome-panel { padding: 25px 26px; border: 1px solid #d0e1f1; border-radius: var(--radius); background: #eaf3fc; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
  .welcome-panel h2 { margin-block: 9px; }
  .welcome-panel p:not(.eyebrow) { color: #4b6680; font-size: 13px; }
  .detail-grid dt { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
  .detail-grid dd { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
  .link-card { display: flex; flex-direction: column; padding: 20px; text-decoration: none; transition: border-color .18s, transform .18s, box-shadow .18s; }
  .link-card:hover { border-color: #93bce0; transform: translateY(-2px); box-shadow: 0 8px 20px #174f7910; }
  .link-card h3 { margin-bottom: 8px; }
  .link-card p { color: var(--muted); font-size: 13px; }
  .text-link { display: block; color: #1267b6; font-size: 12px; font-weight: 700; margin-top: 20px; }
  .rollout-list { display: flex; flex-direction: column; gap: 18px; }
  .rollout-list > div { display: flex; gap: 14px; }
  .rollout-list strong { font-size: 13px; }
  .rollout-list p { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .rollout-marker { width: 9px; height: 9px; background: #c9d8e7; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
  .rollout-marker.current { background: #1b75c4; box-shadow: 0 0 0 4px #e8f3fc; }
  .form-disclosure summary { font-size: 14px; font-weight: 650; color: #175d9b; }
  .form-disclosure[open] summary { margin-bottom: 20px; }
  .form-disclosure > p { margin-bottom: 20px; font-size: 13px; }
  .message { font-size: 13px; padding: 12px 14px; border: 1px solid #c9dff3; border-radius: 9px; background: #eef6fe; color: #244e75; overflow-wrap: anywhere; }
  .message.error { background: #fff2f0; border-color: #f2c7c0; color: #9b3628; }
  #workspace-notices:empty, .form-feedback:empty { display: none; }
  #workspace-notices:not(:empty) { margin-bottom: 18px; }
  .table-panel { padding: 0; overflow: hidden; }
  .table-scroll { overflow-x: auto; scrollbar-width: none; }
  .table-scroll::-webkit-scrollbar { display: none; }
  table { border-collapse: collapse; text-align: left; width: 100%; font-size: 12px; }
  th { color: #5b7189; background: #fafcfe; font-weight: 650; padding: 13px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  td { padding: 16px 18px; border-bottom: 1px solid #edf1f6; vertical-align: top; min-width: 90px; }
  tr:last-child td { border-bottom: 0; }
  td strong { font-size: 12px; font-weight: 650; }
  .long-text { min-width: 140px; max-width: 280px; overflow-wrap: anywhere; }
  .badge { display: inline-block; background: #fff6e3; color: #85601c; border-radius: 6px; padding: 4px 8px; font-size: 10px; font-weight: 650; text-transform: capitalize; white-space: nowrap; }
  .badge.positive { background: #eaf6f0; color: #247851; }
  .badge.muted { background: #f0f2f5; color: #617184; }
  .pagination { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--muted); }
  .decision-form { min-width: 210px; display: flex; flex-direction: column; gap: 8px; }
  .decision-form .field { font-size: 11px; }
  .role-options { display: flex; flex-wrap: wrap; gap: 12px 20px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; margin: 0; }
  .role-options legend { font-size: 12px; color: var(--muted); padding: 0 5px; }
  .role-options .field { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
  .empty-state { padding: 30px 20px; color: var(--muted); font-size: 13px; text-align: center; }
  .loading-placeholder { min-height: 180px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
  .workspace-switches { display: flex; gap: 8px; flex-wrap: wrap; }
  .login-page { max-width: 1100px; min-height: 100svh; margin: auto; padding: 48px 30px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 56px; align-items: center; }
  .login-story { min-height: 550px; padding: 34px; background: #e8f2fc; border: 1px solid #d4e3f2; border-radius: 24px; display: flex; flex-direction: column; justify-content: space-between; gap: 36px; }
  .login-story h1 { font-size: clamp(32px, 4vw, 46px); max-width: 350px; margin: 18px 0; letter-spacing: -.04em; }
  .login-story p:not(.eyebrow) { color: #4d6985; }
  .login-benefits { margin-top: 32px; display: flex; flex-direction: column; gap: 14px; font-size: 12px; color: #315a80; }
  .login-benefits span::before { content: ''; display: inline-block; width: 6px; height: 6px; background: #337cc1; border-radius: 50%; margin-right: 11px; vertical-align: middle; }
  .login-story .story-footnote { font-size: 11px; }
  .login-card { padding: 16px 8px; display: flex; flex-direction: column; gap: 16px; }
  .login-card > h2 { font-size: 30px; }
  .login-card .form-stack { margin-top: 8px; }
  .login-card > .subtle { font-size: 13px; margin-top: -6px; }
  .login-links { margin-top: 6px; display: flex; justify-content: space-between; gap: 18px; font-size: 12px; color: #2769a4; }
  .login-links a { text-underline-offset: 3px; }
}

@layer responsive {
  @media (max-width: 900px) {
    .workspace-layout { grid-template-columns: 166px minmax(0, 1fr); }
    .workspace-sidebar { padding-inline: 10px; }
    .workspace-main { padding: 26px 22px 40px; }
    .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-page { gap: 30px; padding-inline: 24px; }
    .login-story { padding: 26px; }
    .action-panel { align-items: flex-start; flex-direction: column; gap: 16px; }
  }
  @media (max-width: 640px) {
    body { font-size: 13px; }
    input, select, textarea { font-size: 16px; }
    .workspace-header { padding: 0 16px; height: 64px; gap: 12px; }
    .brand { font-size: 24px; }
    .header-brand { gap: 10px; }
    .workspace-tag { padding-left: 10px; font-size: 10px; }
    .header-account { gap: 8px; }
    .header-account .user-name { display: none; }
    .header-account .button { min-height: 40px; }
    .workspace-layout { display: block; min-height: calc(100svh - 64px); }
    .workspace-sidebar { padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .workspace-nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 5px; overscroll-behavior-x: contain; }
    .workspace-nav::-webkit-scrollbar { display: none; }
    .nav-link { flex-shrink: 0; padding: 10px 13px; min-height: 44px; text-align: center; font-size: 12px; border-radius: 8px; }
    .sidebar-note { display: none; }
    .workspace-main { padding: 23px 16px 36px; }
    .page-heading { margin-bottom: 20px; }
    .page-heading h1 { font-size: 27px; }
    .today-label { font-size: 10px; }
    .page-heading .eyebrow { font-size: 9px; }
    .content-stack { gap: 16px; }
    .panel { padding: 18px; }
    .table-panel { padding: 0; }
    .welcome-panel { padding: 19px; align-items: flex-start; }
    .welcome-panel h2 { font-size: 22px; }
    .welcome-panel .button { min-height: 40px; padding: 9px 12px; font-size: 11px; }
    .welcome-panel p:not(.eyebrow) { font-size: 12px; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric-card { padding: 15px; }
    .metric-card strong { font-size: 27px; }
    .metric-card p { font-size: 11px; }
    .section-heading h2 { font-size: 19px; }
    .section-heading p { font-size: 12px; }
    .section-heading > .button { padding: 9px 12px; font-size: 11px; }
    .form-grid { gap: 14px; }
    .form-grid .field { min-width: 0; }
    .form-grid > .field:first-child { grid-column: 1/-1; }
    .button-row { flex-wrap: nowrap; }
    .button-row > .button { flex: 1; }
    .action-panel .button-row { width: 100%; }
    .link-grid { grid-template-columns: 1fr; gap: 10px; }
    .link-card { padding: 18px; }
    .text-link { margin-top: 14px; }
    .pagination { padding-inline: 12px; }
    th { padding: 12px 14px; }
    td { padding: 14px; }
    .login-page { display: flex; flex-direction: column; gap: 18px; min-height: 100svh; padding: 20px 20px 36px; align-items: stretch; max-width: 480px; }
    .login-story { min-height: auto; gap: 22px; border-radius: 18px; padding: 24px; }
    .login-story h1 { font-size: 29px; margin: 10px 0; max-width: 260px; }
    .login-story .eyebrow { font-size: 9px; }
    .login-story > .brand { font-size: 25px; }
    .login-story p:not(.eyebrow) { font-size: 12px; }
    .login-benefits, .login-story .story-footnote { display: none; }
    .login-card { padding: 8px 4px; gap: 12px; }
    .login-card > h2 { font-size: 27px; }
    .login-card .form-stack { gap: 15px; }
  }
  @media (max-width: 350px) {
    .workspace-tag { display: none; }
    .today-label { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid > .field:first-child { grid-column: auto; }
    .welcome-panel { flex-direction: column; gap: 12px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  }
}
