/* D21 Light Gateway V2 adapted to D27's native shell. Domain/status colors stay authoritative. */
:root {
    --dg-ink: #163654;
    --dg-blue: #1768ad;
    --dg-copper: #b85522;
    --dg-copper-light: #efa650;
    --dg-green: #07865b;
    --dg-paper: #f8f5ef;
    --dg-muted: #40596e;
    --dg-radius: 3px;
    --ink: var(--dg-ink);
    --muted: var(--dg-muted);
    --brand: var(--dg-blue);
    --accent: var(--dg-blue);
    --accent-soft: #e8f1fa;
    --line: #cbd9e4;
    --text: var(--dg-ink);
    color-scheme: light;
}

body.dg-premium {
    color: var(--dg-ink);
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: radial-gradient(ellipse at 100% 0%, #bbd6f1 0%, transparent 54%),
        radial-gradient(ellipse at 0% 95%, #efd0a4 0%, transparent 55%),
        linear-gradient(135deg, #fcf8f0, #edf3f8 60%, #d8e7f2);
    background-attachment: fixed;
}
body [hidden] { display: none !important; }
body :is(a, button, summary, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid #1768ad; outline-offset: 3px; }
body button, body input, body select, body textarea { font: inherit; }
body button, body .button { border-radius: var(--dg-radius); }
body button:disabled, body .button[aria-disabled="true"] { cursor: not-allowed; opacity: .65; }
body a { text-underline-offset: 3px; }
body h1 { color: var(--dg-ink); font-size: clamp(24px, 2.2vw, 32px); line-height: 1.2; letter-spacing: -.7px; font-weight: 650; }
body h2 { color: var(--dg-ink); font-size: 20px; line-height: 1.3; letter-spacing: -.3px; }
body h3 { color: var(--dg-ink); font-size: 16px; }
body .muted { color: var(--dg-muted); }
.dg-skip-link { position: fixed; left: 16px; top: -100px; z-index: 1100; background: #fff; color: #163654; padding: 10px 16px; }
.dg-skip-link:focus { top: 12px; }

body .topbar {
    min-height: 76px;
    padding: 13px 26px 0;
    flex-wrap: wrap;
    gap: 10px 14px;
    background: #fffdf9f5;
    border-bottom: 1px solid #bed0e0;
    box-shadow: 0 3px 14px #1647790b;
    backdrop-filter: blur(14px);
}
body .brand { gap: 12px; color: #155a97; text-decoration: none; }
body .product-logo { width: 143px; height: 42px; object-fit: contain; }
.dg-product-caption { max-width: 112px; padding-left: 14px; border-left: 1px solid #d3dbe1; color: #456077; font-size: 11px; line-height: 1.45; }
body .topbar-user { display: block; color: #3c5b75; font-size: 12px; max-width: 230px; white-space: normal; overflow-wrap: anywhere; }
body .topbar-search { width: min(300px, 23vw); margin-left: 10px; }
body .topbar-search input { min-width: 0; background: #f8fbff; font-size: 12px; }
body .topbar-search button { font-size: 12px; }
body .topbar-announcements, body .logout-form button {
    border: 1px solid #c5d3df; background: #fffefa; color: #174f80;
    border-radius: 3px; padding: 7px 11px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
body .topbar-announcements:hover, body .logout-form button:hover { background: #eaf2fa; border-color: #8daecb; }
body .topbar > .ai-guide-launcher { border-radius: 3px; padding: 8px 11px; font-size: 12px; }
body .topbar:not(:has(> .dg-navigation)) { padding-bottom: 13px; }

/* The original permission-checked sidebar becomes a native horizontal menu. */
body .dg-navigation {
    position: relative; z-index: 25; display: flex; align-items: stretch; flex-wrap: wrap;
    gap: 0; padding: 0 18px; background: linear-gradient(110deg, #113a69, #1d639c 68%, #164c7d);
    box-shadow: 0 5px 15px #124d7c25;
}
body .topbar > .dg-navigation { order: 20; flex: 0 0 calc(100% + 52px); margin: 2px -26px 0; }
body .dg-navigation .sidebar {
    display: flex; align-items: stretch; flex-wrap: wrap; gap: 0; position: static;
    width: auto; flex: 1 1 auto; margin: 0; padding: 0; border: 0; border-radius: 0;
    overflow: visible; background: transparent; box-shadow: none; transition: none;
}
body .dg-navigation .sidebar-identity { display: none; }
body .dg-navigation .nav-group { margin: 0; }
body .dg-navigation .nav-group:not(:has(details)) { display: flex; flex-wrap: wrap; }
body .dg-navigation .nav-group > .nav-link { width: auto; }
body .dg-navigation :is(.nav-group > .nav-link, .nav-summary, .dg-shortcuts > summary) {
    display: flex; align-items: center; gap: 8px; min-height: 49px; margin: 0;
    padding: 12px 13px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
    color: #fffdfa; background: transparent; font-size: 12px; font-weight: 600;
    text-decoration: none; list-style: none; cursor: pointer; box-shadow: none;
}
body .dg-navigation .nav-icon { color: #d5e5f4; }
body .dg-navigation :is(.nav-group > .nav-link, .nav-summary, .dg-shortcuts > summary):hover,
body .dg-navigation :is(.nav-group > .nav-link, .nav-summary).active,
body .dg-navigation details[open] > summary { background: #ffffff12; border-bottom-color: var(--dg-copper-light); }
body .dg-navigation summary::-webkit-details-marker { display: none; }
body .dg-navigation summary::after { content: "⌄"; color: #d5e5f4; margin-left: auto; font-size: 13px; }
body .dg-navigation :is(summary, .nav-group > .nav-link):focus-visible { outline-color: #ffe0a9; outline-offset: -4px; }
body .dg-navigation :is(.nav-sub, .module-nav) {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px;
    margin: 0; padding: 16px; background: #fffdf9; border: 1px solid #c2d1df;
    border-top: 2px solid var(--dg-copper-light); border-radius: 0 0 3px 3px;
}
body .dg-navigation details:not([open]) > :is(.nav-sub, .module-nav) { display: none; }
body .dg-navigation :is(.nav-sub .nav-link, .module-nav a) {
    min-height: 42px; padding: 10px 12px; color: #254a69; background: #edf3f9;
    border-radius: 3px; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere;
    white-space: normal; text-decoration: none;
}
body .dg-navigation :is(.nav-sub .nav-link, .module-nav a):hover,
body .dg-navigation :is(.nav-sub .nav-link, .module-nav a).active { background: #dcecfb; color: #164d7c; }
body .dg-navigation-ready :is(.nav-sub, .module-nav) {
    position: absolute; left: 18px; right: 18px; top: 100%; z-index: 40;
    max-height: min(65vh, 580px); overflow-y: auto; box-shadow: 0 20px 35px #16365426;
}
body .dg-shortcuts { margin: 0; }
body .layout { display: block; min-height: calc(100vh - 130px); }
body .content { padding: 27px 30px 38px; }
body main { max-width: 1680px; }
body .section-heading-row { border-bottom-color: #c9d8e3; }
body .dg-eyebrow { margin-bottom: 7px; color: #36546e; font-size: 10px; font-weight: 650; letter-spacing: 1.7px; text-transform: uppercase; }
body .dg-dashboard-hero { margin-bottom: 25px; padding: 6px 0 23px; align-items: center; }
body .dg-dashboard-hero h1 { margin-bottom: 8px; font-weight: 600; }
body .dg-dashboard-eyebrow { margin-bottom: 9px; color: #5c6c76; font-size: 10px; font-weight: 650; letter-spacing: 1.6px; }

/* Shared surfaces only: native table layouts and semantic status colors are preserved. */
body .panel, body .card {
    border-radius: var(--dg-radius); border: 1px solid #faffff;
    border-bottom-color: #b8cddd; border-right-color: #bdd0df;
    background: linear-gradient(130deg, #fffffffa, #ffffffd6);
    box-shadow: 0 7px 20px #16477910, 0 1px 0 #fff inset;
}
body .panel { padding: 19px 21px; margin-bottom: 18px; backdrop-filter: blur(12px); }
body .panel > h2:first-child { margin-top: 0; }
body input:not([type="checkbox"]):not([type="radio"]), body select, body textarea { border-color: #b8c9d8; border-radius: 3px; background-color: #fffefa; color: #163654; }
body input[type="checkbox"], body input[type="radio"] { accent-color: var(--dg-blue); }
body label { color: #284a67; }
body th { color: #224e73; background: #e8f0f7; border-bottom-color: #bdcedd; }
body td { border-bottom-color: #e0e7ec; }
body .local-tabs a { border-radius: 3px; color: #315879; background: #fffdf8; }
body .local-tabs a.active { background: #e4eff9; border-color: #90b2cf; color: #154e7f; }
body .compact-form, body .check-card, body .dof-workflow, body .organization-logo-preview, body .detail-grid div { border-radius: 3px; }

/* Guest login retains the native POST/CSRF/remember contract. */
body.dg-guest .layout { min-height: calc(100vh - 76px); }
body.dg-guest .content { padding: 40px 24px; }
.dg-login { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); width: min(100%, 1050px); margin: max(18px, 4vh) auto; border: 1px solid #c1d3e0; background: #fffdfa; box-shadow: 0 24px 65px #16365419; }
.dg-login-intro { position: relative; min-height: 490px; padding: 47px 45px; overflow: hidden; background: radial-gradient(ellipse at 20% 20%, #fff9ed, transparent 68%), linear-gradient(135deg, #e4edf3, #b7d5e7); }
.dg-login-intro > :not(.dg-login-portal) { position: relative; z-index: 1; }
.dg-login-intro h2 { margin: 16px 0; max-width: 400px; font-size: clamp(30px, 3.5vw, 43px); line-height: 1.16; font-weight: 600; }
.dg-login-intro p { max-width: 345px; color: #35546d; font-size: 15px; line-height: 1.7; }
.dg-login-signature { margin-top: 100px; color: #3d5c73; font-size: 11px; letter-spacing: 1px; }
.dg-login-portal { position: absolute; right: -30px; bottom: -75px; width: 210px; height: 310px; transform: rotate(-12deg); border: 2px solid #fae4bc; background: #fff3; box-shadow: -9px 0 22px #50a4bd4d, 9px 0 30px #dba0685e, 0 0 0 10px #f4f4e56b; }
.dg-login-portal span { position: absolute; inset: 13px; border: 1px solid #fffc; }
body .dg-login-panel { padding: 47px 40px 34px; margin: 0; border: 0; border-top: 3px solid var(--dg-copper); border-radius: 0; box-shadow: none; background: #fffdf9; }
.dg-login-panel h1 { font-size: 27px; margin: 12px 0 9px; }
.dg-login-panel > p { font-size: 13px; }
.dg-login-panel form { margin-top: 25px; }
.dg-login-panel label { margin-top: 18px; font-weight: 600; }
.dg-login-panel input:not([type="checkbox"]) { min-height: 45px; }
.dg-login-panel .dg-remember { display: flex; align-items: center; gap: 9px; margin: 20px 0; font-size: 13px; }
.dg-remember input { width: 17px; min-height: 17px; height: 17px; margin: 0; }
body .dg-login-submit { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 46px; padding: 11px 15px; background: var(--dg-blue); }
.dg-login-help { margin-top: 25px; color: #526b7d; font-size: 11px; line-height: 1.6; }

/* D21's light gateway is hidden by default and skippable whenever enabled. */
#dg-opening { position: fixed; z-index: 1000; inset: 0; overflow: hidden; isolation: isolate; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 48% 25%, #fff9ed 0%, #e0ecf5 47%, #a7c9e1 100%); }
#dg-opening .dg-architecture { position: absolute; inset: 0; background: linear-gradient(108deg, transparent 0 10%, #fff9 10.1% 10.3%, transparent 10.4% 90%, #7e969222 90.1%); pointer-events: none; }
#dg-opening .dg-roomleft, #dg-opening .dg-roomright { position: absolute; top: 0; bottom: 0; width: 26%; border-inline: 1px solid #ffffff70; }
#dg-opening .dg-roomleft { left: 0; clip-path: polygon(0 0, 100% 14%, 100% 77%, 0 100%); background: linear-gradient(100deg, #5789bd4f, #f9f5ec40); }
#dg-opening .dg-roomright { right: 0; clip-path: polygon(0 14%, 100% 0, 100% 100%, 0 77%); background: linear-gradient(100deg, #e6cdaa60, #6999bd49); }
#dg-opening .dg-floor { position: absolute; left: -20%; right: -20%; top: 72%; height: 70%; background: linear-gradient(180deg, #eef0e680, #cad9e4b5), repeating-linear-gradient(90deg, transparent 0 140px, #748e8c33 141px 142px); transform: perspective(380px) rotateX(58deg); transform-origin: top; border-top: 1px solid #ffffffa0; }
#dg-opening .dg-floorlight { position: absolute; top: 72%; left: 20%; width: 60%; height: 24%; background: radial-gradient(ellipse at 50% 0%, #edc695a3, transparent 66%); filter: blur(6px); }
#dg-opening .dg-portal { position: absolute; left: 50%; top: 42%; width: 37%; height: 54%; transform: translate(-50%, -50%); border: 2px solid #fae4bc; background: linear-gradient(135deg, #ffffff30, #bfdbdd2b); box-shadow: -9px 0 22px #50a4bd4d, 9px 0 30px #dba0685e, 0 0 0 9px #f4f4e587, 0 0 0 10px #8198944a; }
#dg-opening .dg-portal::before { content: ""; position: absolute; inset: -11px; border: 1px solid #ffffffba; }
#dg-opening .dg-portal::after { content: ""; position: absolute; inset: 10px; border: 1px solid #fff8; }
#dg-opening .dg-lightline { position: absolute; top: 8%; bottom: 27%; left: 50%; width: 2px; background: #fff9da; box-shadow: 0 0 14px 4px #ffdca6, 0 0 65px 13px #d89d5f55; }
#dg-opening .dg-introbrand { position: relative; z-index: 2; text-align: center; margin-top: -6vh; width: 90%; }
#dg-opening .dg-kicker { color: #284b66; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 15px; }
#dg-opening .dg-intro-logo { display: block; width: min(440px, 74vw); height: auto; max-height: 160px; object-fit: contain; margin: 0 auto; }
#dg-opening .dg-introcaption { font-size: 11px; letter-spacing: 2px; color: #284b66; margin-top: 17px; }
#dg-opening .dg-introbase { position: absolute; bottom: 32px; left: 20px; right: 20px; text-align: center; font-size: 10px; letter-spacing: 2.4px; color: #284b66; }
#dg-opening .dg-skip { position: absolute; top: 22px; right: 25px; background: #fffdf9ed; border: 1px solid #93adc1; color: #16476d; padding: 9px 17px; margin: 0; font-size: 12px; z-index: 5; }
body.dg-entering { overflow: hidden; }
body.dg-entering > .app-shell { transform-origin: 50% 43%; animation: dg-arrive 4.4s cubic-bezier(.23,.5,.19,1) both; }
body.dg-entering #dg-opening { animation: dg-roomfade 4.4s ease both; }
body.dg-entering #dg-opening :is(.dg-architecture,.dg-roomleft,.dg-roomright,.dg-floor,.dg-floorlight) { animation: dg-environment 4.4s ease both; }
body.dg-entering #dg-opening .dg-portal { animation: dg-passthrough 4.4s cubic-bezier(.32,.02,.38,1) both; }
body.dg-entering #dg-opening .dg-introbrand { animation: dg-brandexit 4.4s ease both; }
body.dg-entering #dg-opening .dg-lightline { animation: dg-lightopen 4.4s ease both; }
@keyframes dg-roomfade { 0%,25% { opacity: 1; } 88%,100% { opacity: 0; } }
@keyframes dg-environment { 0%,28% { opacity: 1; } 65%,100% { opacity: 0; } }
@keyframes dg-arrive { 0%,22% { transform: scale(.26); opacity: .05; filter: blur(4px); } 40% { opacity: .55; filter: blur(1px); } 100% { transform: scale(1); opacity: 1; filter: blur(0); } }
@keyframes dg-passthrough { 0% { transform: translate(-50%,-50%) scaleX(.015); opacity: .6; box-shadow: 0 0 32px #dc9954; } 28% { transform: translate(-50%,-50%) scaleX(1); opacity: 1; box-shadow: 0 0 23px #dba36f, 0 0 0 2200px #e8eef4ec; } 48% { box-shadow: 0 0 32px #dba36f, 0 0 0 2200px #e8eef4e6; } 90%,100% { transform: translate(-50%,-50%) scale(5); opacity: 0; box-shadow: 0 0 32px #dba36f, 0 0 0 2200px #e8eef400; } }
@keyframes dg-brandexit { 0% { opacity: 0; transform: translateY(9px); } 18%,35% { opacity: 1; transform: translateY(0); } 57%,100% { opacity: 0; transform: translateY(-20px) scale(1.1); } }
@keyframes dg-lightopen { 0% { transform: scaleY(.08); opacity: 0; } 18% { transform: scaleY(1); opacity: 1; } 39%,100% { opacity: 0; } }

@media (max-width: 1200px) {
    .dg-product-caption { display: none; }
    body .topbar-search { width: min(280px, 26vw); }
    body .dg-navigation :is(.nav-group > .nav-link, .nav-summary, .dg-shortcuts > summary) { padding-inline: 10px; }
}
@media (max-width: 900px) {
    body .topbar { padding: 10px 16px 0; gap: 8px 10px; }
    body .topbar > .dg-navigation { flex-basis: calc(100% + 32px); margin: 2px -16px 0; }
    body .topbar-search { order: 10; width: 100%; margin: 0; }
    body .topbar-user { max-width: 160px; font-size: 11px; }
    body .content { padding: 22px 16px; }
    body .dg-navigation { padding: 0 8px; }
    body .dg-navigation :is(.nav-sub, .module-nav) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body .dg-navigation-ready :is(.nav-sub, .module-nav) { left: 8px; right: 8px; }
    #dg-opening .dg-portal { width: 56%; }
    .dg-login-intro { padding: 40px 30px; }
    body .dg-login-panel { padding: 40px 30px 30px; }
}
@media (max-width: 600px) {
    body .topbar { position: relative; }
    body .product-logo { width: 118px; height: 36px; }
    body .topbar-user { flex: 1 0 100%; max-width: none; order: 8; }
    body .topbar-spacer { display: none; }
    body .topbar-announcements, body .logout-form button { padding: 7px 8px; font-size: 11px; }
    body .topbar > .ai-guide-launcher { margin-left: auto; }
    body .dg-navigation, body .dg-navigation .sidebar { display: block; }
    body .dg-navigation .nav-group:not(:has(details)) { border-bottom: 1px solid #ffffff24; }
    body .dg-navigation .nav-group > .nav-link { flex: 1 1 auto; font-size: 11px; }
    body .dg-navigation :is(.nav-summary, .dg-shortcuts > summary) { min-height: 43px; }
    body .dg-navigation-ready :is(.nav-sub, .module-nav) { position: static; max-height: none; box-shadow: none; }
    body .dg-navigation :is(.nav-sub, .module-nav) { padding: 10px; gap: 6px; }
    body .panel { padding: 16px 14px; }
    body .section-heading-row { flex-wrap: wrap; gap: 12px; }
    body.dg-guest .content { padding: 24px 16px; }
    .dg-login { grid-template-columns: 1fr; margin: 0 auto; }
    .dg-login-intro { min-height: 0; padding: 28px; }
    .dg-login-intro h2 { font-size: 32px; }
    .dg-login-intro p { font-size: 13px; margin-bottom: 0; }
    .dg-login-signature { display: none; }
    .dg-login-portal { width: 125px; height: 210px; }
    body .dg-login-panel { padding: 30px 28px; }
    #dg-opening .dg-portal { width: 68%; height: 48%; }
    #dg-opening .dg-introcaption { font-size: 10px; letter-spacing: 1.2px; }
}
.dg-environment-notice { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 20px; padding: 12px 16px; border: 1px solid #d9ac79; border-left: 4px solid #a75d22; border-radius: 3px; color: #68431f; background: #fff6e9; font-size: 13px; }
.dg-environment-notice strong { white-space: nowrap; }
@media (max-width: 380px) {
    body .dg-navigation :is(.nav-sub, .module-nav) { grid-template-columns: 1fr; }
    body .topbar { gap: 8px; }
}
@media (pointer: coarse) {
    body .dg-navigation :is(summary, .nav-link, .module-nav a), #dg-opening .dg-skip { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    body.dg-entering > .app-shell, #dg-opening, #dg-opening * { animation: none !important; transition: none !important; }
    #dg-opening { display: none !important; }
    body.dg-entering { overflow: auto; }
}
@media print {
    body .topbar, body .dg-navigation, .dg-skip-link, #dg-opening { display: none !important; }
    body.dg-premium { color: #111; background: #fff; }
    body .layout, body .content, body main { display: block; min-height: 0; max-width: none; padding: 0; margin: 0; }
    body .panel, body .card { background: #fff; box-shadow: none; backdrop-filter: none; border: 1px solid #bbb; }
    body.dg-entering > .app-shell { animation: none; transform: none; opacity: 1; filter: none; }
}
