:root {
      color-scheme: light;
      --bg: #f5f7f3;
      --panel: #ffffff;
      --ink: #18201f;
      --muted: #61706b;
      --line: #d8e0dc;
      --blue: #2378a8;
      --green: #267461;
      --amber: #a86623;
      --red: #b63e3e;
      --soft-blue: #e7f2f7;
      --soft-green: #e9f4ef;
      --soft-red: #f8e9e9;
      --shadow: 0 18px 42px rgba(27, 44, 41, .10);
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background: var(--bg);
      color: var(--ink);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      letter-spacing: 0;
    }

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

    button {
      border: 0;
      cursor: pointer;
    }

    .login-screen {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 22px;
      background:
        linear-gradient(rgba(245, 247, 243, .86), rgba(245, 247, 243, .94)),
        radial-gradient(circle at 20% 20%, rgba(35, 120, 168, .18), transparent 34%),
        radial-gradient(circle at 86% 18%, rgba(242, 207, 106, .22), transparent 30%);
    }

    .login-card {
      width: min(100%, 430px);
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
      padding: 24px;
    }

    .login-card .brand {
      color: var(--ink);
      margin-bottom: 20px;
    }

    .login-card .brand p {
      color: var(--muted);
    }

    .login-form {
      display: grid;
      gap: 14px;
    }

    .login-error {
      display: none;
      padding: 10px 12px;
      border-radius: 6px;
      background: var(--soft-red);
      color: var(--red);
      font-size: 13px;
      font-weight: 700;
    }

    .login-error.visible {
      display: block;
    }

    .demo-users {
      margin-top: 18px;
      border-top: 1px solid var(--line);
      padding-top: 16px;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
    }

    .demo-users strong {
      color: var(--ink);
    }

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

    .shell.signed-out {
      display: none;
    }

    .sidebar {
      background: #16312f;
      color: #eef8f6;
      padding: 24px;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .brand {
      display: flex;
      gap: 12px;
      align-items: center;
      min-width: 0;
    }

    .mark {
      width: 42px;
      height: 42px;
      border-radius: 8px;
      background: linear-gradient(135deg, #8dd7dd, #f2cf6a);
      display: grid;
      place-items: center;
      color: #132624;
      font-weight: 800;
    }

    .brand h1 {
      font-size: 18px;
      line-height: 1.1;
      margin: 0;
    }

    .brand p {
      margin: 3px 0 0;
      color: #b8cfca;
      font-size: 13px;
    }

    .account-card {
      border: 1px solid rgba(255, 255, 255, .16);
      border-radius: 8px;
      padding: 14px;
      background: rgba(255, 255, 255, .06);
    }

    .account-card label {
      color: #c9dbd7;
      display: block;
      font-size: 12px;
      margin-bottom: 7px;
    }

    .account-card select {
      width: 100%;
      background: #f7fbfa;
      color: #142422;
      border: 1px solid transparent;
      border-radius: 6px;
      min-height: 42px;
      padding: 0 10px;
    }

    .signed-in-name {
      color: #fff;
      font-weight: 800;
      margin-bottom: 4px;
    }

    .signed-in-role {
      color: #c9dbd7;
      font-size: 13px;
      margin-bottom: 12px;
    }

    .nav {
      display: grid;
      gap: 8px;
    }

    .nav button {
      min-height: 44px;
      border-radius: 6px;
      background: transparent;
      color: #dceceb;
      text-align: left;
      padding: 0 12px;
    }

    .nav button.active {
      background: #eef8f6;
      color: #142422;
    }

    .nav button.hidden {
      display: none;
    }

    .sidebar-footer {
      margin-top: auto;
      color: #aac5c0;
      font-size: 13px;
      line-height: 1.45;
    }

    main {
      min-width: 0;
      padding: 28px;
    }

    .topbar {
      display: flex;
      gap: 16px;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 22px;
    }

    .title h2 {
      margin: 0;
      font-size: 30px;
      line-height: 1.05;
    }

    .title p {
      margin: 7px 0 0;
      color: var(--muted);
    }

    .date-pill {
      border: 1px solid var(--line);
      background: var(--panel);
      border-radius: 8px;
      padding: 10px 13px;
      min-width: 150px;
      color: var(--muted);
      text-align: right;
      box-shadow: 0 8px 24px rgba(27, 44, 41, .05);
    }

    .view {
      display: none;
    }

    .view.active {
      display: block;
    }

    .grid {
      display: grid;
      grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
      gap: 20px;
      align-items: start;
    }

    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
    }

    .panel-header {
      padding: 18px 18px 0;
    }

    .panel-header h3 {
      margin: 0;
      font-size: 18px;
    }

    .panel-header p {
      margin: 6px 0 0;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.4;
    }

    form {
      padding: 18px;
      display: grid;
      gap: 14px;
    }

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

    .field label {
      color: #394844;
      font-size: 13px;
      font-weight: 700;
    }

    input,
    select,
    textarea {
      width: 100%;
      min-height: 44px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fbfcfb;
      color: var(--ink);
      padding: 0 12px;
    }

    textarea {
      min-height: 88px;
      padding: 10px 12px;
      resize: vertical;
    }

    input:focus,
    select:focus,
    textarea:focus {
      outline: 3px solid rgba(35, 120, 168, .16);
      border-color: var(--blue);
    }

    .two-col {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }

    .primary {
      min-height: 48px;
      border-radius: 6px;
      background: var(--green);
      color: #fff;
      font-weight: 800;
    }

    .secondary {
      min-height: 42px;
      border-radius: 6px;
      background: #edf3f1;
      color: #1d3632;
      font-weight: 700;
    }

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

    .icon-danger {
      min-height: 32px;
      border-radius: 6px;
      padding: 0 10px;
      background: var(--soft-red);
      color: var(--red);
      font-size: 12px;
      font-weight: 800;
    }

    .icon-muted {
      min-height: 32px;
      border-radius: 6px;
      padding: 0 10px;
      background: #edf3f1;
      color: #1d3632;
      font-size: 12px;
      font-weight: 800;
    }

    .row-actions {
      display: flex;
      gap: 7px;
      align-items: center;
      white-space: nowrap;
    }

    .role-note {
      padding: 10px 12px;
      border-radius: 6px;
      background: var(--soft-blue);
      color: #20506a;
      font-size: 13px;
      line-height: 1.35;
    }

    .stat-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(140px, 1fr));
      gap: 12px;
      margin-bottom: 20px;
    }

    .stat {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 16px;
      min-height: 104px;
    }

    .stat span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      text-transform: uppercase;
    }

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

    .filters {
      display: flex;
      gap: 10px;
      margin-bottom: 14px;
      flex-wrap: wrap;
    }

    .filters select {
      width: auto;
      min-width: 170px;
      background: #fff;
    }

    .table-wrap {
      overflow: auto;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 760px;
    }

    th,
    td {
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      text-align: left;
      vertical-align: top;
      font-size: 14px;
    }

    th {
      color: #56645f;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0;
      background: #f8faf9;
    }

    .status {
      display: inline-flex;
      min-height: 26px;
      align-items: center;
      border-radius: 999px;
      padding: 0 9px;
      font-size: 12px;
      font-weight: 800;
      white-space: nowrap;
    }

    .ok {
      background: var(--soft-green);
      color: var(--green);
    }

    .warn {
      background: #fff1dc;
      color: var(--amber);
    }

    .bad {
      background: var(--soft-red);
      color: var(--red);
    }

    .chart {
      padding: 18px;
      display: grid;
      gap: 14px;
    }

    .bar-row {
      display: grid;
      grid-template-columns: 95px minmax(0, 1fr) 58px;
      gap: 10px;
      align-items: center;
      font-size: 13px;
      color: var(--muted);
    }

    .bar-track {
      height: 12px;
      border-radius: 999px;
      background: #e6ece9;
      overflow: hidden;
    }

    .bar-fill {
      height: 100%;
      border-radius: 999px;
      background: var(--blue);
    }

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

    .manager-only {
      display: none;
    }

    .can-manage .manager-only {
      display: block;
    }

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

      .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 14px;
        gap: 12px;
      }

      .brand {
        align-items: center;
      }

      .mark {
        width: 36px;
        height: 36px;
      }

      .brand h1 {
        font-size: 16px;
      }

      .account-card {
        padding: 10px;
      }

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

      .sidebar-footer {
        display: none;
      }

      main {
        padding: 18px 14px 28px;
      }

      .topbar {
        display: block;
      }

      .date-pill {
        margin-top: 12px;
        text-align: left;
      }

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

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

    @media (max-width: 560px) {
      .title h2 {
        font-size: 24px;
      }

      .two-col {
        grid-template-columns: 1fr;
      }

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

      .filters {
        display: grid;
      }

      .filters select,
      .filters button {
        width: 100%;
      }

      .bar-row {
        grid-template-columns: 82px minmax(0, 1fr) 48px;
      }
    }
