/* DPPmanager - GUS / Portfolio design system, modern application shell.
   Palette and rules: primary #4869a0, text #1a1a2e, secondary text #4e5865, border #e1e5ea, background #f7f8fa,
   cards white with 1px border and 12px radius, controls 44px high, sentence case, text contrast >= 4.5:1, no emoji. */

:root {
  --gus-primary: #4869a0;
  --gus-primary-hover: #3b567f;
  --gus-primary-soft: #eef2f8;
  --gus-primary-tint: #dde5f1;
  --gus-text: #1a1a2e;
  --gus-text-secondary: #4e5865;
  --gus-border: #e1e5ea;
  --gus-bg: #f7f8fa;
  --gus-success: #356b4c;
  --gus-success-bg: #edf6f1;
  --gus-warning: #8f5413;
  --gus-warning-bg: #fef5e9;
  --gus-danger: #932b2b;
  --gus-danger-bg: #fcedec;

  --radius-card: 12px;
  --radius-control: 10px;
  --shadow-card: 0 1px 2px rgba(26, 26, 46, 0.04), 0 8px 24px rgba(26, 26, 46, 0.04);
  --shadow-pop: 0 8px 28px rgba(26, 26, 46, 0.14);
  --sidebar-w: 264px;

  --bs-body-font-family: "Century Gothic", Futura, "Trebuchet MS", sans-serif;
  --bs-body-color: var(--gus-text);
  --bs-body-bg: var(--gus-bg);
  --bs-secondary-color: var(--gus-text-secondary);
  --bs-border-color: var(--gus-border);
  --bs-primary: var(--gus-primary);
  --bs-primary-rgb: 72, 105, 160;
  --bs-link-color: var(--gus-primary);
  --bs-link-hover-color: var(--gus-primary-hover);
  --bs-link-color-rgb: 72, 105, 160;
  --bs-link-hover-color-rgb: 59, 86, 127;
  --bs-offcanvas-width: 288px;
}

/* ---- Base */
html { font-size: 15px; position: relative; min-height: 100%; }
@media (min-width: 768px) { html { font-size: 16px; } }

body { background: var(--gus-bg); color: var(--gus-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { letter-spacing: -0.01em; }
h1.h3, .h3 { font-weight: 600; }
h2.h5, .h5 { font-weight: 600; }
a { text-underline-offset: 3px; }
code { color: #3b567f; background: var(--gus-primary-soft); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.88em; }
.text-secondary { color: var(--gus-text-secondary) !important; }
.icon { flex: 0 0 auto; vertical-align: -0.2em; }
.skip-link { position: absolute; left: -999px; top: 0.5rem; background: #fff; color: var(--gus-primary); padding: 0.5rem 0.9rem; border-radius: 8px; z-index: 2000; }
.skip-link:focus { left: 0.75rem; }

a:focus-visible, .btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus, .btn-icon:focus-visible, .side-link:focus-visible, summary:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.15rem #fff, 0 0 0 0.3rem var(--gus-primary);
}

/* ---- Buttons and controls (44px high) */
.btn, .form-control, .form-select { min-height: 44px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; border-radius: var(--radius-control); font-weight: 600; transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s; }
.btn-sm { min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.875rem; border-radius: 9px; }
.btn-primary { --bs-btn-bg: var(--gus-primary); --bs-btn-border-color: var(--gus-primary); --bs-btn-hover-bg: var(--gus-primary-hover); --bs-btn-hover-border-color: var(--gus-primary-hover); --bs-btn-active-bg: var(--gus-primary-hover); --bs-btn-active-border-color: var(--gus-primary-hover); --bs-btn-disabled-bg: var(--gus-primary); --bs-btn-disabled-border-color: var(--gus-primary); box-shadow: 0 1px 2px rgba(72, 105, 160, 0.3); }
.btn-outline-primary { --bs-btn-color: var(--gus-primary); --bs-btn-border-color: #c3d0e4; --bs-btn-hover-bg: var(--gus-primary-soft); --bs-btn-hover-color: var(--gus-primary-hover); --bs-btn-hover-border-color: var(--gus-primary); --bs-btn-active-bg: var(--gus-primary-tint); --bs-btn-active-color: var(--gus-primary-hover); --bs-btn-active-border-color: var(--gus-primary); background: #fff; }
.btn-outline-danger { --bs-btn-color: var(--gus-danger); --bs-btn-border-color: #e8c3c2; --bs-btn-hover-bg: var(--gus-danger-bg); --bs-btn-hover-color: var(--gus-danger); --bs-btn-hover-border-color: var(--gus-danger); --bs-btn-active-bg: var(--gus-danger-bg); --bs-btn-active-color: var(--gus-danger); background: #fff; }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--gus-text); }
.btn-ghost:hover, .btn-ghost[aria-expanded="true"] { background: var(--gus-primary-soft); color: var(--gus-primary-hover); }
.btn-icon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: var(--radius-control); color: var(--gus-text); }
.btn-icon:hover { background: var(--gus-primary-soft); color: var(--gus-primary-hover); }

.form-control, .form-select { border-radius: var(--radius-control); border-color: #cfd6df; background-color: #fff; }
.form-control:hover, .form-select:hover { border-color: #aebbd0; }
.form-label { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.form-text { color: var(--gus-text-secondary); }
.form-check-input:checked { background-color: var(--gus-primary); border-color: var(--gus-primary); }
.field-validation-error, .text-danger, .validation-summary-errors { color: var(--gus-danger) !important; font-size: 0.9rem; }
.dropdown-menu { border: 1px solid var(--gus-border); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); padding: 0.4rem; min-width: 14rem; }
.dropdown-item { border-radius: 8px; padding: 0.55rem 0.75rem; display: flex; align-items: center; gap: 0.6rem; min-height: 40px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--gus-primary-soft); color: var(--gus-primary-hover); }
.dropdown-item[aria-current="true"] { background: var(--gus-primary-soft); font-weight: 600; }
.dropdown-header { color: var(--gus-text-secondary); font-size: 0.78rem; }

/* ---- Cards, tabs, tables, badges, alerts */
.app-card { background: #fff; border: 1px solid var(--gus-border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.app-card .card-body { color: var(--gus-text); }
.app-card dl.row dt { font-weight: 500; }

.app-tabs { gap: 0.25rem; border-bottom: 1px solid var(--gus-border); margin-bottom: 1.25rem !important; flex-wrap: nowrap; overflow-x: auto; }
.app-tabs .nav-link { color: var(--gus-text-secondary); min-height: 42px; display: flex; align-items: center; border-radius: 10px 10px 0 0; white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 600; padding: 0.55rem 1rem; }
.app-tabs .nav-link:hover { color: var(--gus-primary-hover); background: var(--gus-primary-soft); }
.app-tabs .nav-link.active { background: transparent; color: var(--gus-primary); border-bottom-color: var(--gus-primary); }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 0.8rem 1rem; border-color: var(--gus-border); }
.table thead th { color: var(--gus-text-secondary); font-weight: 600; font-size: 0.85rem; background: #fafbfc; border-bottom: 1px solid var(--gus-border); white-space: nowrap; }
.table tbody tr { transition: background-color .12s; }
.table-hover > tbody > tr:hover > *, .app-card .table tbody tr:hover > * { background: #fafbfd; }
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.app-card > .table-responsive { border-radius: var(--radius-card); }
.table-responsive > .table > tbody > tr:last-child > * { border-bottom: 0; }

.badge-status, .badge-soft { display: inline-flex; align-items: center; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge-soft { background: var(--gus-bg); border: 1px solid var(--gus-border); color: var(--gus-text-secondary); font-weight: 500; font-size: 0.75rem; margin-left: 0.5rem; line-height: 1.2; }
.badge-success { background: var(--gus-success-bg); color: var(--gus-success); }
.badge-warning { background: var(--gus-warning-bg); color: var(--gus-warning); }
.badge-danger { background: var(--gus-danger-bg); color: var(--gus-danger); }
.badge-soft-solid { background: #e9edf4; color: #2f4a7a; }

.alert { border-radius: var(--radius-card); border: 1px solid transparent; padding: 0.85rem 1.1rem; }
.alert-success { background: var(--gus-success-bg); color: var(--gus-success); border-color: #cfe5d8; }
.alert-warning { background: var(--gus-warning-bg); color: var(--gus-warning); border-color: #f4dcb9; }
.alert-danger { background: var(--gus-danger-bg); color: var(--gus-danger) !important; border-color: #f0c9c8; }
.alert-link { color: inherit; font-weight: 700; }

.progress { --bs-progress-bar-bg: var(--gus-primary); --bs-progress-bg: var(--gus-border); border-radius: 999px; }

/* ---- DataTables */
.app-card .dt-container { padding: 1rem 1.1rem; }
.app-card .dt-container .form-control, .app-card .dt-container .form-select { min-height: 40px; }
.dt-container .dt-search input { margin-left: 0.5rem; }
.app-card table.dataTable thead th { color: var(--gus-text-secondary); font-weight: 600; font-size: 0.85rem; }
.page-item .page-link { color: var(--gus-primary); border-radius: 8px; margin: 0 2px; border-color: var(--gus-border); min-height: 36px; display: inline-flex; align-items: center; }
.page-item.active .page-link { background: var(--gus-primary); border-color: var(--gus-primary); color: #fff; }
.page-item.disabled .page-link { color: #7b8794; background: transparent; }
.dt-container .dt-info { color: var(--gus-text-secondary); font-size: 0.9rem; }

/* ---- Application shell */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { background: #fff !important; border-right: 1px solid var(--gus-border); width: var(--sidebar-w); display: flex; flex-direction: column; }
@media (min-width: 992px) {
  .app-sidebar { position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); overflow-y: auto; }
}
.offcanvas-lg.app-sidebar { --bs-offcanvas-border-width: 0; --bs-offcanvas-border-color: transparent; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.1rem 0.6rem 1.25rem; }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; color: var(--gus-text); }
.brand:hover { color: var(--gus-text); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--gus-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(72, 105, 160, 0.35); }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }

.side-nav { padding: 0.5rem 0.75rem 1rem; flex: 1 1 auto; }
.side-group { margin-top: 1.1rem; }
.side-group:first-child { margin-top: 0.4rem; }
.side-group-title { padding: 0 0.75rem 0.4rem; font-size: 0.78rem; font-weight: 600; color: var(--gus-text-secondary); }
.side-link { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; padding: 0.5rem 0.75rem; border-radius: var(--radius-control); color: var(--gus-text); text-decoration: none; font-weight: 500; position: relative; transition: background-color .12s, color .12s; }
.side-link .side-icon { color: var(--gus-text-secondary); }
.side-link:hover { background: var(--gus-primary-soft); color: var(--gus-primary-hover); }
.side-link:hover .side-icon { color: var(--gus-primary); }
.side-link.active { background: var(--gus-primary-soft); color: var(--gus-primary-hover); font-weight: 700; }
.side-link.active .side-icon { color: var(--gus-primary); }
.side-link.active::before { content: ""; position: absolute; left: -0.75rem; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gus-primary); }
.sidebar-foot { padding: 1rem 1.25rem 1.25rem; font-size: 0.8rem; color: var(--gus-text-secondary); border-top: 1px solid var(--gus-border); }

.app-column { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 90; display: flex; align-items: center; gap: 0.5rem; min-height: 64px; padding: 0.5rem clamp(1rem, 3vw, 2.5rem); background: rgba(247, 248, 250, 0.88); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--gus-border); }
.topbar-spacer { flex: 1 1 auto; }
.app-main { flex: 1 1 auto; width: 100%; max-width: 1360px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 2.5rem; }
.app-main > h1.h3:first-of-type, .app-main > .mt-4:first-of-type { margin-top: 0 !important; }
.app-footer { padding: 1rem clamp(1rem, 3vw, 2.5rem); color: var(--gus-text-secondary); font-size: 0.85rem; border-top: 1px solid var(--gus-border); background: #fff; }
.app-footer a { color: var(--gus-primary); }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gus-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; }
.user-button { gap: 0.6rem; padding: 0.25rem 0.55rem; }
.user-meta { display: inline-flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: 0.9rem; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 0.75rem; color: var(--gus-text-secondary); }

/* ---- Guest shell (landing, sign-in, invitations) */
.guest-header { background: #fff; border-bottom: 1px solid var(--gus-border); padding: 0.7rem 0; }
.guest-container { max-width: 1100px; }
.guest-main { padding: 2rem 0 3rem; min-height: calc(100vh - 150px); }
.guest-footer { margin-top: 0; }

.auth-card { max-width: 520px; margin: 1.5rem auto 0; background: #fff; border: 1px solid var(--gus-border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: clamp(1.25rem, 4vw, 2.25rem); }
.auth-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.25rem; }
.auth-card h2 { font-size: 1.05rem; font-weight: 500; color: var(--gus-text-secondary); margin-bottom: 1.25rem; }
.auth-card h3 { font-size: 1.05rem; }
.auth-card hr { display: none; }
.auth-card .row { display: block; margin: 0; }
.auth-card .row > [class*="col-"] { width: 100%; max-width: 100%; flex: 0 0 100%; padding: 0; }
.auth-card .row > [class*="col-"]:nth-child(2) { display: none; }   /* second column of sign-in and registration: external providers, none configured */
.auth-card .form-floating > .form-control { min-height: 56px; }
.auth-card .btn.w-100 { margin-top: 0.5rem; }
.auth-card p { margin-bottom: 0.45rem; }

.hero { background: radial-gradient(1200px 400px at 85% -10%, #dde5f1 0%, rgba(221, 229, 241, 0) 60%), linear-gradient(135deg, #eef2f8 0%, #ffffff 65%); border: 1px solid var(--gus-border); border-radius: 20px; padding: clamp(1.75rem, 5vw, 3.5rem); box-shadow: var(--shadow-card); }
.hero h1 { font-size: clamp(1.8rem, 4.2vw, 2.9rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; max-width: 18ch; }
.hero p.lead { font-size: 1.1rem; color: var(--gus-text-secondary); max-width: 52ch; }
.hero .btn { min-width: 150px; }
.feature-card { height: 100%; padding: 1.4rem; }
.feature-card h3 { font-size: 1.05rem; font-weight: 700; margin: 0.9rem 0 0.35rem; }
.feature-card p { color: var(--gus-text-secondary); margin: 0; }
.icon-chip { width: 44px; height: 44px; border-radius: 12px; background: var(--gus-primary-soft); color: var(--gus-primary); display: inline-flex; align-items: center; justify-content: center; }
.step-number { width: 32px; height: 32px; border-radius: 50%; background: var(--gus-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }

/* ---- Overview (dashboard) */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }
.page-header .sub { color: var(--gus-text-secondary); margin: 0.2rem 0 0; }
.stat-tile { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; height: 100%; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.stat-tile:hover { border-color: #b6c6de; box-shadow: 0 2px 4px rgba(26, 26, 46, 0.05), 0 12px 28px rgba(26, 26, 46, 0.08); transform: translateY(-1px); color: inherit; }
.stat-tile .icon-chip { width: 48px; height: 48px; }
.app-stat-label { color: var(--gus-text-secondary); font-size: 0.9rem; }
.app-stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.panel-title { font-size: 1.02rem; font-weight: 700; margin: 0 0 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.todo-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--gus-border); text-decoration: none; color: var(--gus-text); }
.todo-row:first-of-type { border-top: 0; }
.todo-row:hover { color: var(--gus-primary-hover); }
.todo-count { min-width: 2.2rem; text-align: center; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; }
.segbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--gus-border); }
.segbar > span { display: block; height: 100%; }
.seg-success { background: #4f9b73; }
.seg-warning { background: #d9962f; }
.seg-danger { background: #c25252; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0.45rem; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* ---- Traceability tree */
.trace-tree { list-style: none; padding-left: 0; margin: 0; }
.trace-tree .trace-tree { margin-left: 1.1rem; padding-left: 1.1rem; border-left: 2px solid var(--gus-primary-tint); }
.trace-item { margin: 0.4rem 0; }
.trace-summary { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; cursor: pointer; padding: 0.65rem 0.9rem; border: 1px solid var(--gus-border); border-radius: var(--radius-control); background: #fff; list-style: none; transition: border-color .12s, background-color .12s; }
.trace-summary::-webkit-details-marker { display: none; }
.trace-summary:hover { background: var(--gus-primary-soft); border-color: #b6c6de; }
.trace-notshared { border-style: dashed; color: var(--gus-text-secondary); }
.trace-body { padding: 0.8rem 0.9rem 0.25rem; }

/* ---- Public passport page */
.public-body { background: var(--gus-bg); }
.public-header { background: #fff; border-bottom: 1px solid var(--gus-border); padding: 0.85rem 0; }
.public-brand { color: var(--gus-primary); font-weight: 700; display: inline-flex; align-items: center; gap: 0.6rem; }
.public-container { max-width: 780px; }
.public-hero { background: linear-gradient(135deg, #eef2f8 0%, #fff 70%); border: 1px solid var(--gus-border); border-radius: 16px; padding: 1.4rem 1.4rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow-card); }
.public-hero h1 { font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 700; margin: 0 0 0.2rem; }
.public-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.public-chip { display: inline-flex; align-items: center; gap: 0.35rem; background: #fff; border: 1px solid var(--gus-border); border-radius: 999px; padding: 0.2rem 0.7rem; font-size: 0.82rem; color: var(--gus-text-secondary); }
.public-footer { border-top: 1px solid var(--gus-border); background: #fff; color: var(--gus-text-secondary); padding: 1rem 0; margin-top: 1.5rem; }
.public-footer a { color: var(--gus-primary); }
.public-body .app-card h2 { font-size: 1.05rem; font-weight: 700; }
.public-body .app-card h3 { color: var(--gus-text-secondary); font-weight: 600; font-size: 0.85rem !important; }

/* ---- Small screens */
@media (max-width: 575.98px) {
  .app-main { padding-top: 1.1rem; }
  .page-header { margin-bottom: 1rem; }
  .table > :not(caption) > * > * { padding: 0.65rem 0.7rem; }
}

/* Small "i" help button next to a field label; opens a popover with the field description. */
.info-hint { width: 24px; height: 24px; margin-left: .5rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--gus-primary); border-radius: 50%; background: #fff; color: var(--gus-primary); font: italic 700 .8rem/1 Georgia, serif; vertical-align: middle; cursor: pointer; }
.info-hint:hover, .info-hint:focus-visible { background: var(--gus-primary); color: #fff; }
