:root {
    --m365-blue: #f59e0b;
    --m365-blue-dark: #b45309;
    --m365-rail: #241506;
    --m365-pane: #ffffff;
    --bg: #fff9ed;
    --panel: #ffffff;
    --ink: #211a12;
    --muted: #786b5c;
    --line: #eadfce;
    --soft: #fff3d6;
    --green: #107c41;
    --amber: #b7791f;
    --red: #c24135;
    --shadow: 0 10px 30px rgba(120, 53, 15, .09);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    letter-spacing: 0;
}
a { color: var(--m365-blue-dark); text-decoration: none; }

.app-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: 56px;
    background: var(--m365-rail);
    display: grid;
    grid-auto-rows: 44px;
    gap: 8px;
    justify-items: center;
    padding: 10px 0;
    z-index: 20;
}
.waffle, .rail-item {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #f7ead7;
    background: transparent;
    font-weight: 700;
    cursor: pointer;
}
.rail-item.active, .rail-item:hover, .waffle:hover {
    background: rgba(245, 158, 11, .22);
    color: #fff;
}
.waffle {
    grid-template-columns: repeat(2, 6px);
    grid-template-rows: repeat(2, 6px);
    gap: 4px;
}
.waffle span {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: currentColor;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 56px;
    width: 278px;
    background: var(--m365-pane);
    border-right: 1px solid var(--line);
    padding: 18px 16px;
    overflow: auto;
    z-index: 15;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #facc15);
    font-weight: 800;
}
.brand-logo-svg {
    width: 27px;
    height: 32px;
}
.rail-logo {
    background: linear-gradient(135deg, #f59e0b, #facc15);
    color: #211a12;
}
.rail-logo-svg {
    width: 23px;
    height: 28px;
}
.brand strong { display: block; line-height: 1.15; }
.brand small { color: var(--muted); text-transform: uppercase; font-size: 11px; font-weight: 800; letter-spacing: .05em; }

.sidebar-search {
    display: grid;
    gap: 7px;
    padding: 0 0 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.sidebar-search label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}
.sidebar-search div { position: relative; }
.sidebar-search input {
    height: 40px;
    padding-left: 36px;
    background: #fffaf1;
}
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: #a16207;
}

.tenant-switcher {
    display: grid;
    gap: 7px;
    padding: 12px;
    margin-bottom: 18px;
    background: #fffaf1;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.tenant-switcher label, .tenant-switcher small {
    color: var(--muted);
    font-size: 12px;
}

.nav-groups { display: grid; gap: 18px; }
.nav-groups section { display: grid; gap: 4px; }
.nav-groups p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.nav-groups a {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 38px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #334155;
    font-weight: 600;
}
.nav-icon {
    width: 20px;
    height: 20px;
    color: #a16207;
    flex: 0 0 auto;
}
.nav-groups a.active, .nav-groups a:hover {
    background: var(--soft);
    color: #1f1306;
}
.nav-groups a.active {
    background: linear-gradient(135deg, #f59e0b, #facc15);
    color: #211a12;
    box-shadow: 0 10px 22px rgba(245, 158, 11, .24);
}
.nav-groups a.active .nav-icon {
    color: #211a12;
}

.shell { margin-left: 334px; padding: 0 24px 32px; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 86px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
    padding: 14px 0;
    background: rgba(255, 249, 237, .9);
    backdrop-filter: blur(14px);
}
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
}
.breadcrumbs strong { color: var(--ink); }
.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 27px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }

.command-bar { display: flex; align-items: center; gap: 10px; }
.tenant-chip {
    min-height: 40px;
    max-width: 260px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px 6px 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 8px 20px rgba(120, 53, 15, .06);
}
.tenant-chip span {
    width: 27px;
    height: 27px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f59e0b, #facc15);
    color: #211a12;
    font-size: 12px;
    font-weight: 900;
}
.tenant-chip strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}
.global-search input {
    width: min(34vw, 410px);
    height: 40px;
    border-radius: 8px;
    background: #fff;
}
.user-chip {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #fff3d6;
    color: var(--m365-blue-dark);
    font-weight: 800;
    border: 1px solid #f7d36d;
}

.sidebar-footer {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.system-status {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: #fffaf1;
    border: 1px solid var(--line);
}
.system-status > span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(16, 124, 65, .12);
}
.system-status strong,
.system-status small {
    display: block;
}
.system-status strong { font-size: 12px; }
.system-status small {
    color: var(--muted);
    font-size: 11px;
}

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    background: #e8f5f1;
    color: var(--green);
    border: 1px solid #b9ddd4;
}
.flash.danger { background: #fff1f0; color: var(--red); border-color: #ffd2cc; }

.kpi-grid, .grid { display: grid; gap: 16px; margin-bottom: 16px; }
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi, .panel, .report-cover, .workspace-tile {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.kpi { padding: 18px; }
.kpi span, .kpi small { color: var(--muted); display: block; }
.kpi strong { display: block; margin: 8px 0; font-size: 24px; }
.kpi.alert { border-top: 4px solid var(--red); }
.kpi.pass { border-top: 4px solid var(--green); }
.panel { padding: 18px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 14px; }

.workspace-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.workspace-tile { display: grid; gap: 5px; padding: 14px; }
.workspace-tile.active { border-color: #f7d36d; background: #fff7df; }
.workspace-tile span { color: var(--muted); font-size: 13px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
}
.data-table td { border-bottom: 1px solid #edf1f6; padding: 11px 8px; vertical-align: middle; }
.number { text-align: right !important; font-variant-numeric: tabular-nums; }
.negative { color: var(--red); }
.pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--m365-blue-dark);
    font-size: 12px;
    font-weight: 650;
}

.checks { display: grid; gap: 10px; }
.check {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.check strong { color: var(--muted); }
.check.pass strong { color: var(--green); }
.check.fail strong { color: var(--red); }
.check.warn strong { color: var(--amber); }
.check span, .check small { display: block; }
.check small { color: var(--muted); margin-top: 3px; }

.workflow-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.workflow-card { display: grid; gap: 9px; padding: 13px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.workflow-card.done { border-color: rgba(16, 124, 65, .35); background: #f0fbf7; }
.workflow-card.in-progress { border-color: rgba(245, 158, 11, .35); background: #fff6dd; }
.workflow-card.blocked { border-color: rgba(194, 65, 53, .35); background: #fff4f2; }

.profile-list { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; margin: 0; }
.profile-list dt { color: var(--muted); }
.profile-list dd { margin: 0; }
.tenant-identity {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}
.tenant-identity > div {
    min-width: 0;
    padding: 18px;
    border: 1px solid #f7d36d;
    border-radius: 8px;
    background: linear-gradient(135deg, #fff7df, #fff);
    box-shadow: var(--shadow);
}
.tenant-identity span,
.tenant-identity small {
    display: block;
    color: var(--muted);
}
.tenant-identity span {
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.tenant-identity strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 22px;
}
.tenant-identity small {
    margin-top: 5px;
    overflow-wrap: anywhere;
}

.form-grid, .inline-form { display: grid; gap: 12px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
.inline-form { grid-template-columns: repeat(8, minmax(120px, 1fr)); align-items: end; margin-top: 14px; }
.upload-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-top: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
label.wide { grid-column: 1 / -1; }
.form-section-title {
    padding-top: 8px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    border-top: 1px solid var(--line);
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    font: inherit;
    color: var(--ink);
    background: #fff;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--m365-blue); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
textarea { min-height: 90px; resize: vertical; }
.button, .icon-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #f59e0b, #facc15);
    color: #211a12;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
}
.button.ghost, .icon-button.subtle { background: #fff; color: var(--m365-blue-dark); border: 1px solid var(--line); }
.icon-button { width: 40px; height: 40px; padding: 0; font-size: 22px; }

.report-cover { padding: 24px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.report-cover p { margin: 0; color: var(--muted); }
.report-cover span { color: var(--muted); }
.hint-box, .empty-state {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
    display: grid;
    gap: 5px;
    font-size: 13px;
}
.hint-box strong { color: var(--ink); }

.search-results { display: grid; gap: 10px; }
.search-result { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .38);
    backdrop-filter: blur(8px);
}
.modal.open { display: grid; }
.modal-panel {
    width: min(620px, 100%);
    max-height: min(88vh, 760px);
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .24);
}
.modal-panel.wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 249, 237, .72);
    backdrop-filter: blur(10px);
}
.page-loader.is-visible {
    display: flex;
}
.page-loader-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 28px 90px rgba(36, 21, 6, .2);
}
.loader-logo-wrap {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #211a12;
    background: rgba(245, 158, 11, .14);
    border: 1px solid #f7d36d;
}
.loader-logo-svg {
    width: 32px;
    height: 38px;
}
.loader-title {
    font-size: 14px;
    font-weight: 800;
}
.loader-bars {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.loader-bars span {
    width: 32px;
    height: 6px;
    border-radius: 999px;
    background: #f59e0b;
    animation: bizauthLoaderPulse 900ms ease-in-out infinite;
    opacity: .35;
}
.loader-bars span:nth-child(2) { animation-delay: 120ms; }
.loader-bars span:nth-child(3) { animation-delay: 240ms; }
@keyframes bizauthLoaderPulse {
    0%, 80%, 100% { transform: scaleX(.55); opacity: .35; }
    40% { transform: scaleX(1); opacity: 1; }
}

.install-body {
    background: linear-gradient(135deg, #241506 0%, #92400e 46%, #fff4d6 46%, #fffaf1 100%);
}
.install-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(300px, 480px) minmax(360px, 620px);
    gap: 28px;
    align-items: center;
    justify-content: center;
    padding: 32px;
}
.install-hero { color: #fff; display: grid; gap: 14px; }
.install-hero h1 { font-size: 40px; }
.install-hero p { margin: 0; max-width: 520px; color: #fff3d6; line-height: 1.55; }
.install-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.install-steps span { padding: 8px 10px; border-radius: 999px; background: rgba(255,255,255,.14); }
.install-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .25);
}
.install-logo svg {
    width: 28px;
    height: 34px;
}
.install-form {
    display: grid;
    gap: 16px;
}
.install-form fieldset {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffaf1;
}
.install-form legend {
    padding: 0 8px;
    color: var(--ink);
    font-weight: 800;
}
.install-form .form-grid {
    margin-top: 6px;
}
.wide-action { grid-column: 1 / -1; }

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(250, 204, 21, .35), transparent 28%),
        linear-gradient(135deg, #241506 0%, #7c2d12 44%, #fff4d6 44%, #fffaf1 100%);
}
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 560px) minmax(360px, 520px);
    gap: 34px;
    align-items: center;
    justify-content: center;
    padding: 34px;
}
.login-brand-panel {
    color: #fff;
    display: grid;
    gap: 18px;
}
.login-logo-row {
    display: flex;
    gap: 12px;
    align-items: center;
}
.login-logo-mark {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #211a12;
    background: linear-gradient(135deg, #f59e0b, #facc15);
    box-shadow: 0 18px 35px rgba(245, 158, 11, .28);
}
.login-logo-mark svg {
    width: 36px;
    height: 42px;
}
.login-logo-row strong,
.login-logo-row small {
    display: block;
}
.login-logo-row small {
    color: #fff3d6;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
}
.login-brand-panel h1 {
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1;
    max-width: 680px;
}
.login-brand-panel p {
    max-width: 560px;
    color: #fff3d6;
    line-height: 1.6;
    margin: 0;
}
.login-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 180px));
    gap: 10px;
}
.login-feature-grid span {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .13);
    border: 1px solid rgba(255, 255, 255, .16);
    font-weight: 700;
}
.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 30px 90px rgba(36, 21, 6, .25);
}
.login-card-head {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}
.login-card-head p {
    color: var(--muted);
    margin: 0;
}
.login-secret-form {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}
.login-primary {
    width: 100%;
    min-height: 44px;
}
.disabled-link {
    pointer-events: none;
    opacity: .48;
    filter: grayscale(.3);
}

@media (max-width: 1100px) {
    .app-rail { position: static; width: auto; grid-auto-flow: column; grid-auto-columns: 44px; height: 56px; }
    .sidebar { position: static; width: auto; margin: 0; }
    .shell { margin-left: 0; padding: 12px; }
    .kpi-grid, .grid.two, .form-grid, .install-shell, .login-shell { grid-template-columns: 1fr; }
    .inline-form, .upload-form { grid-template-columns: 1fr 1fr; }
    .topbar, .report-cover { align-items: stretch; flex-direction: column; }
    .command-bar { flex-wrap: wrap; }
    .tenant-identity { grid-template-columns: 1fr; }
    .tenant-chip { max-width: 100%; }
    .global-search input { width: 100%; }
}

@media (max-width: 620px) {
    .inline-form, .upload-form, .profile-list { grid-template-columns: 1fr; }
    .install-shell { padding: 18px; }
    .install-hero h1 { font-size: 30px; }
    .login-shell { padding: 18px; }
    .login-feature-grid { grid-template-columns: 1fr; }
}

@media print {
    .app-rail, .sidebar, .topbar .button, .topbar .icon-button, .report-cover form { display: none; }
    .shell { margin: 0; padding: 0; }
    body { background: #fff; }
    .panel, .report-cover { box-shadow: none; break-inside: avoid; }
}
