:root{
  /* ICCASS Product UI Tokens — dark default */
  --bg: #070A10;
  --bg-elev: #0B0F19;
  --surface-1: rgba(255,255,255,0.06);
  --surface-2: rgba(255,255,255,0.085);
  --surface-3: rgba(255,255,255,0.11);
  --stroke: rgba(255,255,255,0.14);
  --stroke-2: rgba(255,255,255,0.14);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.74);
  --muted-2: rgba(255,255,255,0.60);

  --accent: #79B4FF;
  --accent-2: #A58BFF;
  --danger: #FF5A66;
  --warning: #FFCA5C;
  --success: #4CE08A;

  --focus-ring: rgba(110,168,255,0.42);

  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;

  --shadow: 0 18px 50px rgba(0,0,0,0.55);
  --shadow-sm: 0 10px 26px rgba(0,0,0,0.45);

  --ease: cubic-bezier(.22,.9,.2,1);
  --dur-1: 140ms;
  --dur-2: 220ms;
  --shell-header-height: 72px;
  --sidebar-width-collapsed: 88px;
  --sidebar-width-expanded: 292px;
}

html[data-theme="light"]{
  color-scheme: light;
  --bg: #EEF3FA;
  --bg-elev: #F7FAFF;
  --surface-1: rgba(255,255,255,0.90);
  --surface-2: rgba(255,255,255,0.96);
  --surface-3: rgba(255,255,255,0.98);
  --stroke: rgba(12,18,34,0.16);
  --stroke-2: rgba(12,18,34,0.16);
  --text: rgba(12,18,34,0.92);
  --muted: rgba(12,18,34,0.72);
  --muted-2: rgba(12,18,34,0.60);

  /* Light mode contrast correction */
  --accent: #2E6DFF;
  --danger: #D92D20;
  --warning: #B54708;
  --success: #027A48;

  --shadow: 0 20px 55px rgba(12,18,34,0.18);
  --shadow-sm: 0 10px 24px rgba(12,18,34,0.12);

  --focus-ring: rgba(46,109,255,0.36);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 800px at 18% 0%, rgba(110,168,255,0.14), transparent 55%),
    radial-gradient(900px 700px at 85% 10%, rgba(165,139,255,0.12), transparent 55%),
    var(--bg);
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-attachment: fixed, fixed, fixed;
  color: var(--text);
  /* Default visible so public pages (e.g. landing) never render blank.
     App pages opt-in to fades via .page-fx added by js/auth.js. */
  opacity: 1;
  transition: opacity 160ms var(--ease);
}
/* App page transitions: content fades upward (opt-in via .page-fx). */
body.page-fx{opacity:1}
body.page-fx .content{opacity:0; transform: translateY(10px)}
body.page-fx.page-ready .content{opacity:1; transform:none; transition: opacity 260ms var(--ease), transform 300ms var(--ease)}
body.page-fx.page-exit .content{opacity:0; transform: translateY(-6px); transition: opacity 140ms var(--ease), transform 180ms var(--ease)}
a{color:inherit;text-decoration:none}
small{color:var(--muted)}

/* Smooth theme switching (applied briefly via js/theme.js) */
html.theme-transition, html.theme-transition *{
  transition:
    background-color 320ms var(--ease),
    color 320ms var(--ease),
    border-color 320ms var(--ease),
    box-shadow 320ms var(--ease),
    opacity 320ms var(--ease),
    filter 320ms var(--ease) !important;
}

/* Layout shell */
.shell{display:block}
.sidebar{
  position: fixed;
  top: var(--shell-header-height);
  left: 0;
  width: var(--sidebar-width-collapsed);
  height: calc(100vh - var(--shell-header-height));
  overflow: hidden;
  z-index: 100;
  padding: 20px 14px;
  background: rgba(9, 13, 20, 0.96);
  backdrop-filter: saturate(105%) blur(8px);
  border-right: 1px solid var(--stroke);
  box-shadow: 0 0 0 rgba(0,0,0,0);
  display:flex;
  flex-direction:column;
  gap: 14px;
  transition:
    width var(--dur-2) var(--ease),
    padding var(--dur-2) var(--ease),
    background var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

html[data-theme="light"] .sidebar{
  background: rgba(250, 252, 255, 0.96);
  border-right: 1px solid var(--stroke);
}

.main{
  margin-left:var(--sidebar-width-collapsed);
  min-width:0;
  display:flex;
  flex-direction:column;
  min-height:100vh;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 120;
  height: var(--shell-header-height);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 24px;
  background: rgba(10,12,18,0.78);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: saturate(120%) blur(14px);
  margin-left: calc(-1 * var(--sidebar-width-collapsed));
  width: calc(100% + var(--sidebar-width-collapsed));
}
html[data-theme="light"] .topbar{ background: rgba(247,250,255,0.9); }

.topbar-brand{
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.topbar-meta{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap: 8px;
  min-width: 0;
  min-width: 260px;
  padding: 0;
}
.topbar-meta__row{
  display:grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items:baseline;
  column-gap: 12px;
}
.topbar-meta__label{
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar-meta__value{
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
}
.topbar-meta__value--secondary{
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.content{padding: 22px; overflow:auto; flex:1}

.nav{display:flex;flex-direction:column;gap:8px; padding-top: 6px}

.nav a{
  position: relative;
  overflow: hidden;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text);
  transition:
    transform var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    padding var(--dur-2) var(--ease),
    gap var(--dur-2) var(--ease);
}
.nav a:hover{background:rgba(255,255,255,0.04);border-color:var(--stroke);transform:none}
.nav a.active{background:rgba(121,180,255,0.10);border-color:rgba(121,180,255,0.20)}
.nav a.active::before{
  content:"";
  position:absolute;
  left:0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 99px;
  background: var(--accent);
}

.nav-ico{
  flex: 0 0 auto;
  width:22px;
  height:22px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  opacity:0.9;
}
.nav-ico svg{width:18px;height:18px}
.nav-ico path{fill: currentColor; opacity:0.95}
.sidebar-label{
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease),
    max-width var(--dur-2) var(--ease);
}
.nav-label{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Light mode: ensure active nav state remains clearly visible */
html[data-theme="light"] .nav a.active{
  background: rgba(46,109,255,0.08);
  border-color: rgba(46,109,255,0.18);
}

/* Primary CTA nav item */
/* Press shimmer (applied via JS on click only) */
.nav a::after,
.btn::after{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius: inherit;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: translateX(-140%);
  pointer-events:none;
  mix-blend-mode: screen;
  opacity: 0;
}
.press-shimmer::after{
  opacity: 1;
  transition: transform 700ms var(--ease), opacity 120ms var(--ease);
  transform: translateX(140%);
}

.sidebar-footer{
  margin-top:auto;
  padding-top: 12px;
  border-top: 1px solid var(--stroke);
  display:flex;
  flex-direction:column;
  transition:
    opacity var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease),
    max-height var(--dur-2) var(--ease),
    margin var(--dur-2) var(--ease),
    padding var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}

.sidebar-actions{
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:stretch;
  justify-content:space-between;
  padding-top: 10px;
}
.sidebar-actions .btn{
  width: 100%;
  font-size: 13px;
}
.sidebar-actions .profile-action.active{
  background: rgba(121,180,255,0.10);
  border-color: rgba(121,180,255,0.20);
}
html[data-theme="light"] .sidebar-actions .profile-action.active{
  background: rgba(46,109,255,0.08);
  border-color: rgba(46,109,255,0.18);
}

/* Buttons */
.btn{
  position: relative;
  overflow: hidden;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor:pointer;
  font-weight: 680;
  transition:
    transform var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    padding var(--dur-2) var(--ease),
    gap var(--dur-2) var(--ease);
}
.btn:hover{background:rgba(255,255,255,0.04);border-color:var(--stroke-2);transform:none}
.btn:active{transform: translateY(0px)}
.btn.ghost{background:transparent;border-color:transparent}
.btn.ghost:hover{background:rgba(255,255,255,0.04);border-color:var(--stroke)}

.btn.primary{
  background: linear-gradient(135deg, rgba(110,168,255,0.70), rgba(165,139,255,0.55));
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.94);
  box-shadow: 0 14px 34px rgba(0,0,0,0.35);
  overflow:hidden;
}
/* hover shimmer removed; shimmer occurs on press via .press-shimmer */

.btn.danger{background: rgba(255,90,102,0.08); border-color: rgba(255,90,102,0.18); color: rgba(255,90,102,0.92)}
.btn.danger:hover{background: rgba(255,90,102,0.12); border-color: rgba(255,90,102,0.24)}

.submission-stack{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:1400;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:12px;
  width:min(360px, calc(100vw - 32px));
  pointer-events:none;
}

.submission-card{
  position:relative;
  pointer-events:auto;
  display:grid;
  gap:10px;
  padding:16px 18px 16px;
  border:1px solid rgba(121,180,255,0.5);
  border-radius:16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03)),
    rgba(11,15,25,0.96);
  box-shadow:0 18px 44px rgba(0,0,0,0.34);
  backdrop-filter:saturate(118%) blur(18px);
  cursor:pointer;
  transition:
    transform var(--dur-2) var(--ease),
    opacity 220ms var(--ease),
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.submission-card.is-static{
  cursor:default;
}

.submission-card:hover{
  transform:translateY(-2px);
  border-color:rgba(121,180,255,0.72);
  box-shadow:0 20px 52px rgba(0,0,0,0.38);
}

.submission-card.is-static:hover{
  transform:none;
}

.submission-card:focus-visible{
  outline:2px solid var(--focus-ring);
  outline-offset:2px;
}

.submission-card.is-exiting{
  opacity:0;
  transform:translateY(10px);
}

.submission-card__dismiss{
  position:absolute;
  top:10px;
  right:10px;
  width:28px;
  height:28px;
  border:0;
  border-radius:999px;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  font-size:18px;
  line-height:1;
}

.submission-card__dismiss:hover{
  background:rgba(255,255,255,0.08);
  color:var(--text);
}

.submission-card__eyebrow{
  font-size:11px;
  font-weight:800;
  letter-spacing:0.14em;
  text-transform:uppercase;
  color:var(--muted);
}

.submission-card__title{
  padding-right:28px;
  font-size:16px;
  font-weight:700;
  line-height:1.3;
  color:var(--text);
}

.submission-card__meta{
  display:grid;
  gap:6px;
}

.submission-card__ref{
  color:var(--muted);
  font-size:13px;
  line-height:1.35;
}

.submission-card__steps{
  display:grid;
  gap:8px;
}

.submission-step{
  display:grid;
  grid-template-columns:10px minmax(0, 1fr) auto;
  gap:10px;
  align-items:center;
  color:var(--muted);
  font-size:13px;
  line-height:1.35;
}

.submission-step__dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:rgba(255,255,255,0.28);
}

.submission-step__label{
  min-width:0;
}

.submission-step__detail{
  color:var(--muted-2);
  font-size:12px;
  white-space:nowrap;
}

.submission-step.is-running .submission-step__dot,
.submission-step.is-pending .submission-step__dot{
  background:rgba(255,255,255,0.34);
}

.submission-step.is-complete .submission-step__dot,
.submission-step.is-not_required .submission-step__dot{
  background:var(--success);
}

.submission-step.is-complete .submission-step__label,
.submission-step.is-not_required .submission-step__label,
.submission-step.is-complete .submission-step__detail,
.submission-step.is-not_required .submission-step__detail{
  color:var(--success);
}

.submission-card__risk{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding-top:10px;
  border-top:1px solid var(--stroke);
  font-size:12px;
  color:var(--muted);
}

.submission-card__risk strong{
  font-size:13px;
  font-weight:800;
  color:var(--text);
}

.submission-card__risk .risk-low{ color:var(--success); }
.submission-card__risk .risk-medium{ color:var(--warning); }
.submission-card__risk .risk-high{ color:#ffb366; }
.submission-card__risk .risk-critical{ color:var(--danger); }

html[data-theme="light"] .submission-card{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,255,0.98)),
    rgba(255,255,255,0.98);
  box-shadow:0 18px 40px rgba(12,18,34,0.18);
  border-color:rgba(46,109,255,0.42);
}

html[data-theme="light"] .submission-card__dismiss:hover{
  background:rgba(12,18,34,0.06);
}

@media (max-width: 640px){
  .submission-stack{
    right:12px;
    left:12px;
    bottom:12px;
    width:auto;
  }
}
.btn-label{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inputs */
.field{display:flex;flex-direction:column;gap:6px}
label{font-size:12px;color:var(--muted)}
input,select,textarea{
  width:100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface-1);
  color: var(--text);
  outline:none;
}
input::placeholder,textarea::placeholder{color: var(--muted-2); opacity: 1;}
input:focus,select:focus,textarea:focus,
input:focus-visible,select:focus-visible,textarea:focus-visible{
  border-color: var(--focus-ring);
  /* Fallback first (then enhanced if color-mix is supported) */
  box-shadow: 0 0 0 4px rgba(110,168,255,0.14);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 35%, transparent);
}

html[data-theme="light"] input:focus,html[data-theme="light"] select:focus,html[data-theme="light"] textarea:focus,
html[data-theme="light"] input:focus-visible,html[data-theme="light"] select:focus-visible,html[data-theme="light"] textarea:focus-visible{
  box-shadow: 0 0 0 4px rgba(46,109,255,0.12);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 35%, transparent);
}

/* Prefer keyboard-visible focus where supported */
:where(a,button,input,select,textarea,[role="button"]):focus-visible{
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
textarea{resize:vertical;min-height:120px}

/* Surfaces */
.surface{
  border: 1px solid var(--stroke);
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card{border: 1px solid var(--stroke); background: var(--surface-1); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px}

.hr{height:1px;background:var(--stroke);margin:14px 0}

/* Tables */
.table{width:100%;border-collapse:separate;border-spacing:0}
.table th,.table td{padding:10px 10px;border-bottom:1px solid var(--stroke);text-align:left;font-size:13px}
.table th{color:var(--muted);font-weight:750;background: var(--surface-1)}
.table tr:hover td{background: rgba(110,168,255,0.06)}

/* Chips */
.chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:999px;border:1px solid var(--stroke);font-size:12px;color:var(--muted);background: var(--surface-1)}
.chip.high{color: rgba(255,202,92,0.96); border-color: rgba(255,202,92,0.24); background: rgba(255,202,92,0.10)}
.chip.critical{color: rgba(255,90,102,0.94); border-color: rgba(255,90,102,0.26); background: rgba(255,90,102,0.10)}
.chip.open{color: rgba(110,168,255,0.95); border-color: rgba(110,168,255,0.24); background: rgba(110,168,255,0.10)}
.chip.closed{color: rgba(76,224,138,0.95); border-color: rgba(76,224,138,0.22); background: rgba(76,224,138,0.10)}

/* Light mode: semantic chips must remain readable (avoid yellow-on-white) */
html[data-theme="light"] .chip.high{color: rgba(181,71,8,0.95); border-color: rgba(181,71,8,0.22); background: rgba(181,71,8,0.08)}
html[data-theme="light"] .chip.critical{color: rgba(217,45,32,0.95); border-color: rgba(217,45,32,0.22); background: rgba(217,45,32,0.08)}
html[data-theme="light"] .chip.open{color: rgba(46,109,255,0.95); border-color: rgba(46,109,255,0.22); background: rgba(46,109,255,0.08)}
html[data-theme="light"] .chip.closed{color: rgba(2,122,72,0.95); border-color: rgba(2,122,72,0.22); background: rgba(2,122,72,0.08)}

@media (min-width: 981px){
  .sidebar-label{
    max-width: 172px;
  }

  .sidebar .btn-label{
    opacity: 0;
    transform: translateX(-10px);
    max-width: 0;
    pointer-events: none;
  }

  .sidebar .brand{
    padding-inline: 14px;
  }

  .sidebar .nav a{
    padding-inline: 19px;
  }

  .sidebar .sidebar-footer{
    margin-top: auto;
    padding-top: 12px;
  }

  .sidebar .btn{
    justify-content: flex-start;
    padding-inline: 19px;
  }

  html[data-sidebar-preview="expanded"] .shell > .sidebar,
  .shell > .sidebar:focus-within,
  .shell > .sidebar:hover{
    width: var(--sidebar-width-expanded);
    padding: 20px 14px;
    box-shadow: 16px 0 32px rgba(0,0,0,0.24);
  }

  html[data-sidebar-preview="expanded"] .shell > .sidebar .nav a,
  .shell > .sidebar:focus-within .nav a,
  .shell > .sidebar:hover .nav a{
    padding-inline: 19px;
  }

  html[data-sidebar-preview="expanded"] .shell > .sidebar .btn-label,
  .shell > .sidebar:focus-within .btn-label,
  .shell > .sidebar:hover .btn-label{
    opacity: 1;
    transform: translateX(0);
    max-width: 190px;
    pointer-events: auto;
  }

  html[data-sidebar-preview="expanded"] .shell > .sidebar .sidebar-footer,
  .shell > .sidebar:focus-within .sidebar-footer,
  .shell > .sidebar:hover .sidebar-footer{
    padding-top: 12px;
    border-top-color: var(--stroke);
  }

  html[data-sidebar-preview="expanded"] .shell > .sidebar .sidebar-actions .btn,
  .shell > .sidebar:focus-within .sidebar-actions .btn,
  .shell > .sidebar:hover .sidebar-actions .btn{
    padding-inline: 19px;
  }
}

/* Responsive */
@media (max-width: 980px){
  .sidebar{display:none}
  .main{margin-left:0}
  .topbar{
    margin-left: 0;
    width: 100%;
  }
  .content{padding: 16px}
}

/* Motion preference */
@media (prefers-reduced-motion: reduce){
  *{scroll-behavior:auto !important}
  .sidebar,.nav a,.sidebar-footer,.btn,.sidebar-label,.topbar,.topbar-meta,.topbar-meta__row,.topbar-meta__label,.topbar-meta__value{transition:none !important}
  .press-shimmer::after{transition:none !important}
}
