/* FCCMS — Enterprise Design System */
:root {
  --navy-900: #0f1c2e;
  --navy-800: #1a2b42;
  --navy-700: #243552;
  --navy-600: #2f4466;
  --grey-50: #f5f7fa;
  --grey-100: #e8edf3;
  --grey-200: #d4dce6;
  --grey-300: #b0bccd;
  --grey-400: #8494a7;
  --grey-500: #5c6b7a;
  --grey-600: #3d4a57;
  --white: #ffffff;
  --green-600: #1a7a45;
  --green-100: #e6f5ec;
  --amber-600: #b8860b;
  --amber-100: #fef6e0;
  --orange-600: #c45c12;
  --orange-100: #fff0e6;
  --red-600: #c0392b;
  --red-100: #fdecea;
  --blue-600: #1a5f9e;
  --blue-100: #e8f1fa;
  --sidebar-w: 248px;
  --header-h: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(15, 28, 46, 0.08), 0 1px 2px rgba(15, 28, 46, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 28, 46, 0.1);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Consolas", "Courier New", monospace;
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  color: var(--navy-900);
  background: var(--grey-50);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* —— Login —— */
body.auth-login .app-shell { display: none !important; }
body.auth-app .login-page { display: none !important; }
body.auth-app .app-shell { display: flex !important; }

.login-page {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(26, 95, 158, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(26, 122, 69, 0.12), transparent 50%),
    linear-gradient(145deg, #0c1624 0%, var(--navy-900) 42%, var(--navy-800) 100%);
}

body.auth-login {
  overflow: hidden;
  background: var(--navy-900);
}

.login-ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  animation: loginGridDrift 28s linear infinite;
}

@keyframes loginGridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 48px, 48px 48px; }
}

@keyframes loginRise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  background: var(--white);
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  min-height: 100%;
  max-height: none;
  animation: loginRise 0.45s ease both;
}

.login-aside {
  background:
    linear-gradient(165deg, rgba(26, 95, 158, 0.18) 0%, transparent 42%),
    linear-gradient(160deg, var(--navy-900), var(--navy-700));
  color: var(--white);
  padding: clamp(36px, 5vw, 72px) clamp(32px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

.login-aside::after {
  content: "";
  position: absolute;
  right: -40%;
  bottom: -20%;
  width: 70%;
  height: 55%;
  background: radial-gradient(circle, rgba(255,255,255,0.07), transparent 70%);
  pointer-events: none;
}

.login-aside-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
  animation: loginRise 0.5s ease 0.05s both;
}

.login-aside-brand .logo-mark,
.login-mobile-brand .logo-mark {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.6px;
  flex-shrink: 0;
}

.login-aside-title { font-weight: 700; font-size: 20px; letter-spacing: 1.2px; line-height: 1.1; }
.login-aside-sub { font-size: 12px; opacity: 0.68; margin-top: 3px; }

.login-aside-kicker {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  animation: loginRise 0.5s ease 0.1s both;
}

.login-aside-headline {
  position: relative;
  z-index: 1;
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 14ch;
  animation: loginRise 0.5s ease 0.14s both;
}

.login-aside-copy {
  position: relative;
  z-index: 1;
  font-size: 13px;
  line-height: 1.55;
  opacity: 0.78;
  max-width: 36ch;
  animation: loginRise 0.5s ease 0.18s both;
}

.login-aside-points {
  position: relative;
  z-index: 1;
  margin-top: auto;
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.88;
  animation: loginRise 0.5s ease 0.22s both;
}

.login-aside-points li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.login-aside-points li::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: #5dade2;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.2);
}

.login-aside-plants {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.72);
  animation: loginRise 0.5s ease 0.26s both;
}

.login-aside-plants span + span::before {
  content: "·";
  margin: 0 8px;
  opacity: 0.45;
  font-weight: 400;
}

.login-card {
  background: var(--white);
  padding: clamp(28px, 4vw, 48px) clamp(24px, 4vw, 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  height: 100%;
  -webkit-overflow-scrolling: touch;
}

.login-card-inner {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.login-mobile-brand {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--grey-100);
}

.login-mobile-brand .logo-mark {
  background: var(--navy-800);
  border-color: transparent;
  color: var(--white);
}

.login-mobile-brand .login-aside-title { color: var(--navy-900); }
.login-mobile-brand .login-aside-sub { color: var(--grey-500); opacity: 1; }

.login-brand { margin-bottom: 20px; }

.login-phase {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-600);
  background: var(--blue-100);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.login-brand h1 {
  font-size: clamp(22px, 3vw, 26px);
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.login-brand .subtitle {
  color: var(--grey-500);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.45;
  max-width: 36ch;
}

.login-form .form-group { margin-bottom: 14px; }
.login-form .form-control {
  min-height: 44px;
  padding: 11px 14px;
  font-size: 15px;
  border-radius: 8px;
  background: var(--grey-50);
}
.login-form .form-control:focus { background: var(--white); }
.login-form .btn-primary {
  margin-top: 4px;
  min-height: 46px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}

.password-field { position: relative; }
.password-field .form-control { padding-right: 68px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--blue-600);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  min-height: 36px;
}
.password-toggle:hover { background: var(--blue-100); }

.demo-accounts {
  margin-top: 22px;
  border-top: 1px solid var(--grey-100);
  padding-top: 16px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.demo-accounts-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.demo-accounts h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--grey-400);
  margin: 0;
}

.demo-accounts-note {
  font-size: 11px;
  color: var(--grey-400);
}

.demo-user-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: min(340px, 42vh);
  overflow-y: auto;
  padding: 2px 4px 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--grey-200) transparent;
}

.demo-user-card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--grey-200);
  border-radius: 10px;
  background: var(--grey-50);
  cursor: pointer;
  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}
.demo-user-card:hover,
.demo-user-card:focus-visible {
  border-color: var(--blue-600);
  background: var(--blue-100);
  box-shadow: var(--shadow);
  outline: none;
}
.demo-user-card:active { transform: scale(0.985); }

.duc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--navy-800), var(--navy-700));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.duc-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.duc-role { font-size: 12px; font-weight: 700; color: var(--navy-900); }
.duc-name { font-size: 11px; color: var(--grey-500); }
.duc-cred {
  font-size: 10px;
  color: var(--blue-600);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.duc-blurb {
  font-size: 10px;
  color: var(--grey-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.duc-go {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue-600);
  white-space: nowrap;
  align-self: center;
}

.login-hint {
  margin-top: 12px;
  font-size: 11px;
  color: var(--grey-400);
  line-height: 1.45;
}

.login-hint strong { color: var(--grey-600); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .login-ambient,
  .login-layout,
  .login-aside-brand,
  .login-aside-kicker,
  .login-aside-headline,
  .login-aside-copy,
  .login-aside-points,
  .login-aside-plants { animation: none; }
}

.user-dropdown-meta {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-100);
  font-size: 12px;
  color: var(--grey-500);
}
.user-dropdown-link {
  display: block;
  padding: 10px 14px;
  color: var(--navy-900);
  font-size: 13px;
  text-decoration: none;
}
.user-dropdown-link:hover { background: var(--grey-50); text-decoration: none; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy-900);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(26, 95, 158, 0.15);
}

.form-control.is-invalid {
  border-color: var(--red-600);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  line-height: 1.3;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--navy-800);
  color: var(--white);
  border-color: var(--navy-800);
}
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }

.btn-secondary {
  background: var(--white);
  color: var(--navy-800);
  border-color: var(--grey-200);
}
.btn-secondary:hover:not(:disabled) { background: var(--grey-50); border-color: var(--grey-300); }

.btn-success { background: var(--green-600); color: var(--white); border-color: var(--green-600); }
.btn-success:hover:not(:disabled) { background: #156639; }

.btn-danger { background: var(--red-600); color: var(--white); border-color: var(--red-600); }
.btn-danger:hover:not(:disabled) { background: #a93226; }

.btn-warning { background: var(--orange-600); color: var(--white); border-color: var(--orange-600); }

.btn-ghost {
  background: transparent;
  color: var(--navy-700);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--grey-100); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }
.btn-block { width: 100%; }

.login-error {
  background: var(--red-100);
  color: var(--red-600);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* —— App Shell —— */
.app-shell { display: none; min-height: 100vh; }
.app-shell.active { display: flex; flex-direction: column; }

.app-header {
  height: var(--header-h);
  background: var(--navy-900);
  color: var(--white);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; display: block; }
.menu-toggle:hover { background: rgba(255,255,255,0.1); }

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--white);
}
.header-brand:hover { text-decoration: none; color: var(--white); }

.header-brand .mark {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.header-brand .name { font-weight: 700; font-size: 15px; letter-spacing: 0.8px; }

.factory-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,0.15);
}

.factory-switcher label {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.factory-switcher select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  max-width: 280px;
  cursor: pointer;
}
.factory-switcher select option { color: var(--navy-900); }

.global-search {
  flex: 1;
  max-width: 420px;
  position: relative;
  margin: 0 auto;
}

.global-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.global-search input::placeholder { color: rgba(255,255,255,0.45); }
.global-search input:focus {
  outline: none;
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.3);
}
.global-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.45);
  pointer-events: none;
  display: flex;
  width: 16px;
  height: 16px;
}
.global-search .search-icon svg { width: 16px; height: 16px; }

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-dropdown.open { display: block; }

.search-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-100);
  cursor: pointer;
  color: var(--navy-900);
}
.search-item:hover { background: var(--grey-50); }
.search-item .si-title { font-weight: 600; font-size: 13px; }
.search-item .si-meta { font-size: 11px; color: var(--grey-500); margin-top: 2px; }
.search-empty { padding: 16px; text-align: center; color: var(--grey-400); font-size: 13px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  background: transparent;
  border: none;
  color: var(--white);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn:hover { background: rgba(255,255,255,0.1); }

.badge-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--red-600);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-menu {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--white);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.user-btn:hover { background: rgba(255,255,255,0.14); }
.user-btn .user-chevron {
  display: flex;
  width: 14px;
  height: 14px;
  opacity: 0.7;
}
.user-btn .user-chevron svg { width: 14px; height: 14px; }
.header-crumb {
  display: none;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.12);
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  display: none;
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--navy-900);
  cursor: pointer;
  font-size: 13px;
}
.user-dropdown button:hover { background: var(--grey-50); }

/* —— Layout —— */
.app-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-900);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  color: rgba(255,255,255,0.78);
}

.sidebar-brand-block {
  padding: 18px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 4px;
}
.sidebar-brand-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}
.sidebar-brand-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  margin-top: 2px;
}

.nav-section {
  padding: 14px 0 6px;
}
.nav-section-title {
  padding: 4px 18px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: rgba(255,255,255,0.38);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px 9px 16px;
  margin: 1px 8px;
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-radius: 6px;
  text-decoration: none;
  border-left: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(26, 95, 158, 0.35);
  color: var(--white);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--blue-600);
}
.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}
.nav-item .nav-icon svg { width: 18px; height: 18px; display: block; }
.nav-item .nav-label { flex: 1; line-height: 1.2; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 18px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer-text {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.3px;
}

.page-enter {
  animation: pageFade 0.18s ease;
}
@keyframes pageFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.main-content {
  flex: 1;
  padding: 20px 24px 40px;
  overflow-x: hidden;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy-900);
}
.page-header .page-desc {
  color: var(--grey-500);
  font-size: 13px;
  margin-top: 2px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--grey-400);
  margin-bottom: 8px;
}
.breadcrumb .sep { cursor: default; color: var(--grey-300); }
.breadcrumb a {
  color: var(--grey-400);
  text-decoration: none;
  cursor: pointer;
}
.breadcrumb a:hover { color: var(--blue-600); text-decoration: none; }

a.td-id, a.link-btn {
  text-decoration: none;
}
a.td-id:hover, a.link-btn:hover { text-decoration: underline; }

button.kpi-card {
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

/* Compliance calendar */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  margin-bottom: 4px;
}
.cal-wd {
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border-top: 1px solid var(--grey-200);
  border-left: 1px solid var(--grey-200);
}
.cal-day {
  min-height: 96px;
  border-right: 1px solid var(--grey-200);
  border-bottom: 1px solid var(--grey-200);
  padding: 6px;
  background: var(--white);
}
.cal-day.cal-empty { background: var(--grey-50); }
.cal-day.cal-today { background: var(--blue-100); }
.cal-day-num { font-size: 12px; font-weight: 700; color: var(--navy-800); margin-bottom: 4px; }
.cal-event {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: rgba(26, 95, 158, 0.1);
  color: var(--blue-600);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 5px;
  border-radius: 3px;
  margin-bottom: 3px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event:hover { background: var(--blue-600); color: var(--white); }
.cal-more { font-size: 10px; color: var(--grey-400); }

/* —— Cards —— */
.card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--grey-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2, .card-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-800);
}
.card-body { padding: 16px; }

/* —— Status badges —— */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active { background: var(--green-100); color: var(--green-600); }
.badge-expiring_soon, .badge-expiring { background: var(--amber-100); color: var(--amber-600); }
.badge-critical { background: var(--orange-100); color: var(--orange-600); }
.badge-urgent { background: var(--red-100); color: var(--red-600); }
.badge-expired { background: var(--red-100); color: var(--red-600); }
.badge-under_renewal { background: var(--blue-100); color: var(--blue-600); }
.badge-draft { background: var(--grey-100); color: var(--grey-500); }
.badge-pending_approval, .badge-submitted, .badge-under_verification { background: var(--blue-100); color: var(--blue-600); }
.badge-rejected { background: var(--red-100); color: var(--red-600); }
.badge-scheduled { background: var(--blue-100); color: var(--blue-600); }
.badge-completed, .badge-closed, .badge-pass { background: var(--green-100); color: var(--green-600); }
.badge-open, .badge-fail { background: var(--red-100); color: var(--red-600); }
.badge-observation { background: var(--amber-100); color: var(--amber-600); }
.badge-overdue { background: var(--red-100); color: var(--red-600); }
.badge-info { background: var(--blue-100); color: var(--blue-600); }
.badge-inactive { background: var(--grey-100); color: var(--grey-400); }

/* —— Toast —— */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-left: 4px solid var(--green-600);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn 0.25s ease;
}
.toast.error { border-left-color: var(--red-600); }
.toast.warning { border-left-color: var(--orange-600); }
.toast.info { border-left-color: var(--blue-600); }
.toast .toast-msg { flex: 1; font-size: 13px; }
.toast .toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--grey-400);
  font-size: 16px;
  line-height: 1;
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* —— Modal —— */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 28, 46, 0.55);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 860px;
  margin: auto;
  animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 1040px; }
.modal-sm { max-width: 480px; }

@keyframes modalIn {
  from { transform: translateY(-16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--grey-400);
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--navy-900); }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--grey-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--grey-50);
  border-radius: 0 0 10px 10px;
}

/* —— Notification panel —— */
.notif-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: 380px;
  max-width: 100%;
  height: calc(100vh - var(--header-h));
  background: var(--white);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 150;
  display: none;
  flex-direction: column;
}
.notif-panel.open { display: flex; }
.notif-header {
  padding: 16px;
  border-bottom: 1px solid var(--grey-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notif-header h3 { font-size: 15px; font-weight: 700; }
.notif-list { flex: 1; overflow-y: auto; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--grey-100);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--grey-50); }
.notif-item.unread { background: var(--blue-100); }
.notif-item .ni-title { font-weight: 600; font-size: 13px; }
.notif-item .ni-meta { font-size: 11px; color: var(--grey-500); margin-top: 3px; }
.notif-item .ni-level {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

/* —— Tabs —— */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--grey-100);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  font-weight: 600;
  font-size: 13px;
  color: var(--grey-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--navy-800); }
.tab-btn.active {
  color: var(--blue-600);
  border-bottom-color: var(--blue-600);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* —— Empty / Loading —— */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--grey-400);
}
.empty-state h3 { color: var(--grey-500); margin-bottom: 8px; }

.hidden { display: none !important; }

/* —— Utility —— */
.text-muted { color: var(--grey-500); }
.text-sm { font-size: 12px; }
.text-danger { color: var(--red-600); }
.text-success { color: var(--green-600); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.field-error {
  color: var(--red-600);
  font-size: 11px;
  margin-top: 4px;
  display: none;
}
.field-error.show { display: block; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey-500);
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--grey-100);
}
.section-title:first-child { margin-top: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.detail-grid dt { color: var(--grey-500); font-weight: 500; }
.detail-grid dd { font-weight: 600; color: var(--navy-900); }

.qr-box {
  width: 160px;
  height: 160px;
  border: 2px solid var(--navy-900);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--white);
  margin: 0 auto 12px;
}
.qr-box .cell { background: var(--navy-900); }
.qr-box .cell.off { background: transparent; }

.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--grey-200);
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue-600);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--blue-600);
}
.timeline-item .tl-year {
  font-size: 11px;
  font-weight: 700;
  color: var(--grey-400);
}
.timeline-item .tl-title {
  font-weight: 600;
  font-size: 13px;
  margin-top: 2px;
}
.timeline-item .tl-desc {
  font-size: 12px;
  color: var(--grey-500);
}

.progress-bar {
  height: 8px;
  background: var(--grey-100);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--green-600);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  background: conic-gradient(var(--green-600) calc(var(--score) * 1%), var(--grey-100) 0);
  position: relative;
}
.score-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  background: var(--white);
  border-radius: 50%;
}

.score-ring span { position: relative; z-index: 1; }

@media print {
  .app-header, .sidebar, .page-actions, .btn, .toast-container,
  .notif-panel, .menu-toggle, .modal-overlay, .no-print { display: none !important; }
  .main-content { padding: 0; }
  .app-body { display: block; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
