:root {
  --brand-primary: #0e7490;
  --brand-primary-dark: #0b4f63;
  --brand-sidebar: #0f2740;
  --brand-sidebar-2: #12324d;
  --brand-accent: #14b8a6;
  --brand-accent-soft: #e6faf7;
  --brand-bg: #f1f5f9;
  --brand-card: #ffffff;
  --brand-text: #0f172a;
  --brand-muted: #64748b;
  --brand-border: #e2e8f0;
  --brand-border-strong: #cbd5e1;
  --field-edit: #ffffff;
  --field-readonly: #f1f5f9;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --radius: .65rem;
  --radius-sm: .45rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
  --font: "Noto Sans TC", "Noto Sans SC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--brand-bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 100% -20%, rgba(20, 184, 166, .07), transparent),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(14, 116, 144, .05), transparent);
  color: var(--brand-text);
  min-height: 100vh;
  font-size: .875rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-accent); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(175deg, var(--brand-sidebar) 0%, var(--brand-sidebar-2) 55%, #0c3d52 100%);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(15, 39, 64, .18);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.15rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  min-height: var(--topbar-height);
}

.sidebar .brand .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: .55rem;
  background: linear-gradient(145deg, rgba(20, 184, 166, .35), rgba(14, 116, 144, .4));
  border: 1px solid rgba(125, 224, 219, .25);
  color: #99f6e4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.sidebar .brand .brand-text { min-width: 0; }

.sidebar .brand .brand-title {
  font-weight: 700;
  font-size: .98rem;
  letter-spacing: .01em;
  line-height: 1.25;
  white-space: nowrap;
}

.sidebar .brand small {
  display: block;
  font-weight: 400;
  opacity: .55;
  font-size: .7rem;
  margin-top: .15rem;
}

.sidebar .nav-section {
  padding: 1rem .85rem .35rem;
  font-size: .65rem;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .35);
}

.sidebar nav {
  padding: .35rem .75rem 1rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: rgba(255, 255, 255, .72);
  padding: .62rem .8rem;
  border-radius: .5rem;
  margin-bottom: .15rem;
  font-weight: 500;
  font-size: .875rem;
  line-height: 1.35;
  box-sizing: border-box;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.sidebar nav a .nav-ico,
.sidebar .nav-group-toggle .nav-ico {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  opacity: .85;
  border-radius: .35rem;
  line-height: 1;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
}

.sidebar nav a.active {
  background: rgba(20, 184, 166, .22);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand-accent);
}

.sidebar nav a.active .nav-ico {
  background: rgba(20, 184, 166, .25);
  opacity: 1;
  color: #5eead4;
}

.sidebar .nav-group {
  margin-bottom: .15rem;
}

.sidebar .nav-group-toggle {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  margin: 0 0 .15rem;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  padding: .62rem .8rem;
  border-radius: .5rem;
  font-weight: 500;
  font-size: .875rem;
  font-family: inherit;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  transition: background .15s ease, color .15s ease;
}

.sidebar .nav-group-toggle > span {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar .nav-group-toggle:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
}

.sidebar .nav-group.open > .nav-group-toggle {
  color: #fff;
}

.sidebar .nav-group-toggle .nav-chevron {
  margin-left: auto;
  font-size: .75rem;
  opacity: .55;
  transition: transform .2s ease;
}

.sidebar .nav-group.open > .nav-group-toggle .nav-chevron {
  transform: rotate(180deg);
}

.sidebar .nav-sub {
  display: none;
  padding: .15rem 0 .35rem 0;
  margin: .1rem 0 .2rem .55rem;
  border-left: 1px solid rgba(255, 255, 255, .12);
  padding-left: .55rem;
}

.sidebar .nav-group.open > .nav-sub {
  display: block;
}

.sidebar .nav-sub a {
  padding: .42rem .65rem .42rem .9rem;
  font-size: .8rem;
  margin-bottom: .05rem;
  color: rgba(255, 255, 255, .62);
}

.sidebar .nav-sub a .nav-ico {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 1.15rem;
  font-size: .92rem;
  opacity: .7;
}

.sidebar .nav-sub a:hover {
  color: #fff;
}

.sidebar .nav-sub a.active {
  color: #fff;
}

.sidebar .sidebar-foot {
  padding: .9rem 1.15rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: .68rem;
  color: rgba(255, 255, 255, .35);
  letter-spacing: .02em;
}

.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .65rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--brand-border);
  margin: 0 .15rem;
}

.topbar .user-chip {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--brand-text);
  font-size: .82rem;
  font-weight: 500;
  padding: .28rem .7rem .28rem .35rem;
  background: #fff;
  border: 1px solid var(--brand-border);
  border-radius: 2rem;
  box-shadow: var(--shadow-sm);
}

.topbar .user-chip .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #0e7490, #14b8a6);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
}

.topbar .user-chip .role-tag {
  color: var(--brand-muted);
  font-weight: 400;
  font-size: .75rem;
}

.content {
  padding: 1.5rem 1.65rem 2.25rem;
  flex: 1;
  width: 100%;
  max-width: none;
}

/* ---------- Panels ---------- */
.card-panel {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.15rem;
}

.card-panel--flush {
  padding: 0;
  overflow: hidden;
}

.card-panel--flush .card-toolbar {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--brand-border);
  background: linear-gradient(180deg, #fafbfc, #f8fafc);
}

.card-panel--flush .table-responsive {
  margin: 0;
}

.card-panel > h5,
.card-panel .panel-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .95rem;
  font-weight: 650;
  color: var(--brand-primary-dark);
  margin: 0 0 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--brand-border);
}

.card-panel > h5 .bi,
.card-panel .panel-title .bi {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .4rem;
  background: var(--brand-accent-soft);
  color: var(--brand-primary);
  font-size: .95rem;
}

.panel-title--inline {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.panel-head {
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--brand-border);
}

.dash-feed .list-group-item {
  background: transparent;
  border-color: #f1f5f9;
  padding-top: .7rem;
  padding-bottom: .7rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--brand-text);
  display: flex;
  align-items: center;
  gap: .55rem;
  line-height: 1.3;
  letter-spacing: -.01em;
}

.page-title .bi {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .5rem;
  background: #fff;
  border: 1px solid var(--brand-border);
  color: var(--brand-primary);
  font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
}

.page-subtitle {
  color: var(--brand-muted);
  font-size: .82rem;
  margin-top: .3rem;
  margin-left: 2.7rem;
}

/* ---------- Buttons ---------- */
.btn {
  font-weight: 550;
  border-radius: var(--radius-sm);
  letter-spacing: .01em;
}

.btn-brand {
  background: linear-gradient(180deg, #1289a7, var(--brand-primary));
  border-color: var(--brand-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(14, 116, 144, .25);
}

.btn-brand:hover,
.btn-brand:focus {
  background: linear-gradient(180deg, #14b8a6, #0e7490);
  border-color: var(--brand-accent);
  color: #fff;
}

.btn-accent {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: #fff;
}

.btn-accent:hover,
.btn-accent:focus {
  background: #0d9488;
  border-color: #0d9488;
  color: #fff;
}

.btn-outline-secondary {
  border-color: var(--brand-border-strong);
  color: #475569;
  background: #fff;
}

.btn-outline-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: var(--brand-text);
}

.btn-outline-primary {
  border-color: #99d5e3;
  color: var(--brand-primary);
  background: #fff;
}

.btn-outline-primary:hover {
  background: var(--brand-accent-soft);
  border-color: var(--brand-accent);
  color: var(--brand-primary-dark);
}

.btn .bi {
  margin-right: .35rem;
  vertical-align: -.1em;
}

.btn-sm {
  font-size: .78rem;
  padding: .3rem .6rem;
}

.btn-sm .bi { margin-right: .25rem; }

.btn-icon-action {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

/* ---------- Forms ---------- */
.form-label {
  font-size: .78rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: .35rem;
}

.form-control,
.form-select {
  background-color: var(--field-edit);
  border-color: var(--brand-border-strong);
  color: var(--brand-text);
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-size: .875rem;
  min-height: 2.35rem;
}

.form-control:focus,
.form-select:focus {
  background-color: var(--field-edit);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 .2rem rgba(20, 184, 166, .15);
}

.field-manual,
.form-control.field-manual,
.form-select.field-manual {
  background-color: var(--field-edit) !important;
}

.field-auto,
.form-control.field-auto,
.form-select.field-auto,
.form-control[readonly],
.form-control:disabled,
.form-select:disabled {
  background-color: var(--field-readonly) !important;
  color: #475569;
  cursor: default;
}

.form-control[readonly]:focus,
.form-control:disabled:focus,
.form-select:disabled:focus {
  box-shadow: none;
  border-color: var(--brand-border-strong);
}

/* ---------- Tables ---------- */
.badge-soft {
  background: var(--brand-accent-soft);
  color: #0f766e;
  border: 1px solid #99e6d8;
  font-weight: 600;
  font-size: .72rem;
  padding: .3em .55em;
  border-radius: .35rem;
}

.badge-state {
  font-weight: 650;
  font-size: .72rem;
  padding: .32em .55em;
  border-radius: .35rem;
  border: 1px solid transparent;
  max-width: 100%;
  white-space: nowrap;
}

.badge-state--open {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.badge-state--ip {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.badge-state--fb {
  background: #ecfdf5;
  color: #047857;
  border-color: #6ee7b7;
}

.badge-state--other {
  background: var(--brand-accent-soft);
  color: #0f766e;
  border-color: #99e6d8;
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  --bs-table-border-color: #eef2f6;
}

.table thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--brand-border) !important;
  vertical-align: middle;
  padding-top: .85rem !important;
  padding-bottom: .85rem !important;
}

.table > :not(caption) > * > * {
  padding: .85rem 1rem;
  vertical-align: middle;
}

.table-hover > tbody > tr {
  transition: background .12s ease;
}

.table-hover > tbody > tr:hover > * {
  background-color: #f0fdfa !important;
}

.table-data tbody td {
  font-size: .84rem;
  color: #334155;
}

.table-data tbody td:first-child {
  font-weight: 600;
  color: var(--brand-text);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: .8rem;
}

/* 描述列适度宽度，过长截断 */
.table-data .col-desc {
  width: 18%;
  min-width: 8rem;
  max-width: 14rem;
}
.table-data .col-desc .text-truncate {
  display: block;
  max-width: 100%;
}
.table-data .col-actions {
  width: 1%;
  white-space: nowrap;
}

.wo-row--parent > td {
  background: rgba(13, 110, 108, 0.04);
}
.wo-row--child > td {
  background: rgba(148, 163, 184, 0.06);
}
.wo-tree-indent {
  display: inline-block;
  width: 1.1rem;
  height: .85rem;
  margin-right: .35rem;
  border-left: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  vertical-align: middle;
  opacity: .7;
}
.badge-wo-parent {
  background: #ccfbf1;
  color: #0f766e;
  border: 1px solid #99f6e4;
  font-weight: 600;
  font-size: .72rem;
}
.badge-wo-child {
  background: #e2e8f0;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-weight: 600;
  font-size: .72rem;
}

.table-sm > :not(caption) > * > * {
  padding: .55rem .75rem;
}

.mono-cell {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: .8rem;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--brand-muted);
}

.empty-state .bi {
  font-size: 2.25rem;
  display: block;
  margin-bottom: .65rem;
  opacity: .4;
  color: var(--brand-primary);
}

/* ---------- Lang / reminder ---------- */
.lang-switch .btn {
  border-color: var(--brand-border-strong);
  min-width: 3.2rem;
  font-size: .75rem;
  font-weight: 600;
  background: #fff;
}

.lang-switch .btn.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

.reminder-bell {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .5rem;
  border: 1px solid var(--brand-border);
  background: #fff;
  color: #475569;
  padding: 0;
  transition: all .15s ease;
}

.reminder-bell:hover {
  background: var(--brand-accent-soft);
  color: var(--brand-primary);
  border-color: #99e6d8;
}

.reminder-bell .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: .62rem;
  min-width: 1.1rem;
}

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 18% 22%, rgba(20, 184, 166, .22), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(14, 116, 144, .32), transparent 38%),
    linear-gradient(145deg, #0f2740, #0e7490 48%, #14b8a6);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 1rem;
  padding: 2.1rem 2.15rem 1.85rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .2);
}

.login-card .login-icon {
  width: 52px;
  height: 52px;
  border-radius: .75rem;
  background: linear-gradient(145deg, var(--brand-accent-soft), #d1fae5);
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid #99e6d8;
}

.login-card h1 {
  font-size: 1.4rem;
  color: var(--brand-text);
  margin-bottom: .25rem;
  font-weight: 700;
  text-align: center;
}

.login-card .login-subtitle {
  text-align: center;
}

.login-card .form-control {
  background: var(--field-edit);
  min-height: 2.6rem;
}

.input-icon-wrap {
  position: relative;
}

.input-icon-wrap .bi {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand-muted);
  pointer-events: none;
}

.input-icon-wrap .form-control {
  padding-left: 2.45rem;
}

/* ---------- Tabs / stats ---------- */
.nav-tabs {
  border-bottom: 1px solid var(--brand-border);
  gap: .15rem;
}

.nav-tabs .nav-link {
  color: var(--brand-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: .4rem .4rem 0 0;
  padding: .75rem 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 500;
  font-size: .85rem;
}

.nav-tabs .nav-link:hover {
  color: var(--brand-primary);
  background: #f8fafc;
  border-color: transparent;
}

.nav-tabs .nav-link.active {
  color: var(--brand-primary);
  background: transparent;
  border-color: transparent transparent var(--brand-accent);
  font-weight: 650;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: flex-start;
  gap: .95rem;
  transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-ico {
  width: 44px;
  height: 44px;
  border-radius: .6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--brand-accent-soft);
  color: var(--brand-primary);
  border: 1px solid #b2f0e6;
}

.stat-card .stat-ico.tone-warn {
  background: #fff7ed;
  color: var(--warning);
  border-color: #fed7aa;
}

.stat-card .stat-ico.tone-info {
  background: #e0f2fe;
  color: var(--brand-primary);
  border-color: #bae6fd;
}

.stat-card .label {
  color: var(--brand-muted);
  font-size: .78rem;
  font-weight: 500;
  margin-bottom: .2rem;
}

.stat-card .value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--brand-text);
  line-height: 1.15;
  letter-spacing: -.02em;
}

.filter-bar {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-bottom: 0;
}

.card-toolbar .filter-bar {
  margin: 0;
}

.toolbar-actions {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
  align-items: center;
}

.section-block {
  margin-bottom: 1.35rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--brand-border);
}

.section-block:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.section-block h6 {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 650;
  color: var(--brand-primary-dark);
  margin-bottom: .75rem;
}

.list-group-item {
  border-color: #eef2f5;
}

.progress-mini {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  width: auto;
  max-width: 100%;
}

.progress-mini .bar {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  min-width: 56px;
  max-width: 80px;
}

.progress-mini .bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  border-radius: 3px;
}

.action-group {
  display: inline-flex;
  gap: .35rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.table-data .col-actions .action-group .btn {
  flex-shrink: 0;
}

#toast-area {
  position: sticky;
  top: 0;
  z-index: 1050;
  margin-bottom: .75rem;
}

#toast-area .alert {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 0;
}

/* ---------- Certificate thumbs / lightbox ---------- */
.cert-thumb {
  width: 56px;
  height: 56px;
  border-radius: .4rem;
  border: 1px solid var(--brand-border);
  background: #f8fafc;
  overflow: hidden;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  cursor: zoom-in;
  padding: 0;
  flex-shrink: 0;
  transition: box-shadow .15s ease, border-color .15s ease;
  text-decoration: none;
  color: inherit;
}

.cert-thumb:hover {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .18);
}

.cert-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cert-thumb--pdf {
  color: #dc2626;
  font-size: 1.25rem;
}

.cert-thumb--pdf span {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: #b91c1c;
}

.cert-thumb--file {
  color: var(--brand-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.cert-thumb--empty {
  color: #cbd5e1;
  cursor: default;
  pointer-events: none;
}

.cert-alert-stack {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.cert-alert {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
}

.cert-alert .bi {
  font-size: 1rem;
  flex-shrink: 0;
}

.cert-alert--expired {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.cert-alert--soon {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.cert-table tbody tr.cert-row--expired > *,
.table-data tbody tr.cert-row--expired > * {
  background: #fef2f2 !important;
}

.cert-table tbody tr.cert-row--soon > *,
.table-data tbody tr.cert-row--soon > * {
  background: #fffbeb !important;
}

.cert-table tbody tr.cert-row--expired,
.table-data tbody tr.cert-row--expired {
  box-shadow: inset 3px 0 0 #dc2626;
}

.cert-table tbody tr.cert-row--soon,
.table-data tbody tr.cert-row--soon {
  box-shadow: inset 3px 0 0 #d97706;
}

.cert-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .7rem;
  font-weight: 700;
  padding: .18rem .45rem;
  border-radius: .3rem;
  line-height: 1.2;
  white-space: nowrap;
}

.cert-badge--expired {
  background: #dc2626;
  color: #fff;
}

.cert-badge--soon {
  background: #f59e0b;
  color: #78350f;
}

.cert-date {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cert-date--expired {
  color: #b91c1c;
}

.cert-date--soon {
  color: #b45309;
}

.cert-lightbox[hidden] {
  display: none !important;
}

.cert-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

body.cert-lightbox-open {
  overflow: hidden;
}

.cert-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .8);
  backdrop-filter: blur(2px);
  cursor: zoom-out;
}

.cert-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border-radius: .65rem;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.cert-lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .85rem;
  background: rgba(255, 255, 255, .06);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.cert-lightbox__title {
  color: #f8fafc;
  font-weight: 600;
  font-size: .9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-lightbox__actions {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
}

.cert-lightbox__body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .85rem;
  background: #020617;
}

.cert-lightbox__body img {
  max-width: 100%;
  max-height: calc(92vh - 64px);
  object-fit: contain;
  border-radius: .35rem;
}

.cert-lightbox__body iframe {
  width: 100%;
  height: calc(92vh - 64px);
  min-height: 420px;
  border: 0;
  border-radius: .35rem;
  background: #fff;
}

/* ---------- Confirm dialog ---------- */
.wo-confirm[hidden] {
  display: none !important;
}

.wo-confirm {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

body.wo-confirm-open {
  overflow: hidden;
}

.wo-confirm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
}

.wo-confirm__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  background: #fff;
  border-radius: .85rem;
  padding: 1.5rem 1.4rem 1.25rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
  text-align: center;
  animation: wo-confirm-in .18s ease-out;
}

@keyframes wo-confirm-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.wo-confirm__icon {
  width: 52px;
  height: 52px;
  margin: 0 auto .9rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.wo-confirm--danger .wo-confirm__icon {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.wo-confirm--warn .wo-confirm__icon {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.wo-confirm--primary .wo-confirm__icon {
  background: var(--brand-accent-soft);
  color: var(--brand-primary);
  border: 1px solid #99e6d8;
}

.wo-confirm__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .45rem;
  color: var(--brand-text);
}

.wo-confirm__message {
  margin: 0;
  color: #475569;
  font-size: .9rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.wo-confirm__detail {
  margin: .65rem 0 0;
  padding: .55rem .7rem;
  background: #f8fafc;
  border: 1px solid var(--brand-border);
  border-radius: .45rem;
  color: var(--brand-primary-dark);
  font-size: .82rem;
  font-weight: 600;
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
  white-space: pre-wrap;
  text-align: left;
}

.wo-confirm__actions {
  display: flex;
  gap: .55rem;
  justify-content: center;
  margin-top: 1.2rem;
}

.wo-confirm__actions .btn {
  min-width: 96px;
}

/* ---------- Date / NA / Pending picker ---------- */
.dsp {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.dsp-seg {
  display: inline-flex;
  width: 100%;
  background: #f1f5f9;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.dsp-opt {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--brand-muted);
  font-size: .75rem;
  font-weight: 600;
  padding: .35rem .25rem;
  border-radius: .35rem;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}

.dsp-opt:hover:not(:disabled) {
  color: var(--brand-text);
  background: rgba(255, 255, 255, .7);
}

.dsp-opt.is-active {
  background: #fff;
  color: var(--brand-primary-dark);
  box-shadow: var(--shadow-sm);
}

.dsp-opt[data-dsp-mode="NA"].is-active {
  color: #64748b;
}

.dsp-opt[data-dsp-mode="Pending"].is-active {
  color: #b45309;
}

.dsp-date-wrap .form-control {
  min-height: 2.1rem;
}

.dsp--disabled {
  opacity: .75;
  pointer-events: none;
}

.dsp--disabled .dsp-opt {
  cursor: default;
}

@media (max-width: 992px) {
  .sidebar {
    position: relative;
    width: 100%;
    box-shadow: none;
  }
  .main-wrap { margin-left: 0; }
  .app-shell { flex-direction: column; }
  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .65rem;
  }
  .sidebar nav a {
    margin-bottom: 0;
    flex: 1 1 auto;
  }
  .sidebar nav a.active {
    box-shadow: none;
  }
  .page-subtitle {
    margin-left: 0;
  }
  .content {
    padding: 1.1rem 1rem 1.75rem;
  }
}

.chart-box {
  position: relative;
  height: 260px;
  width: 100%;
}
.chart-box--wide {
  height: 300px;
}
.reports-filters .form-label {
  color: var(--brand-muted, #6c757d);
}
