:root {
  --navy: #0e2744;
  --navy-2: #081a2f;
  --navy-light: #16365a;
  --blue: #1d68e0;
  --blue-hover: #1555bd;
  --blue-2: #edf4fe;
  --blue-border: #d4e3fb;
  --cyan: #effafd;
  --ink: #0f1f33;
  --ink-light: #2c3e55;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-subtle: #edf2f7;
  --bg: #f8fafc;
  --card: #ffffff;
  --ok: #0d8258;
  --ok-bg: #eaf8f1;
  --warn: #b46b04;
  --warn-bg: #fef7ec;
  --danger: #d43b4d;
  --danger-bg: #fdf2f2;
  --shadow-sm: 0 1px 3px rgba(12, 38, 71, 0.04);
  --shadow: 0 4px 16px -2px rgba(12, 38, 71, 0.06);
  --shadow-lg: 0 12px 32px -4px rgba(12, 38, 71, 0.08);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 95% 0, #edf4fe 0, transparent 32%), var(--bg);
  color: var(--ink);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
small { color: var(--muted); }

/* Shell Layout */
.app-shell { min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: linear-gradient(180deg, #0d2744 0%, #081a2f 100%);
  color: #fff;
  padding: 16px 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(8, 26, 47, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-logo-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #ffffff;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  flex-shrink: 0;
}
.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-info strong {
  display: block;
  letter-spacing: 0.5px;
  font-size: 14.5px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}
.brand-info small {
  display: block;
  color: #9bb5cf;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
}

.nav-list { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  position: relative;
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #b7cce1;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(29, 104, 224, 0.32) 0%, rgba(29, 104, 224, 0.12) 100%);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.25);
  font-weight: 650;
}
.nav-item.active:before {
  content: "";
  width: 3.5px;
  height: 20px;
  background: #60a5fa;
  border-radius: 0 4px 4px 0;
  position: absolute;
  left: -12px;
}
.nav-icon {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  color: #9bb5cf;
  transition: color 0.15s, stroke 0.15s;
}
.nav-item .nav-icon {
  color: #9bb5cf;
}
.nav-item:hover .nav-icon {
  color: #ffffff;
}
.nav-item.active .nav-icon {
  color: #60a5fa;
}
.nav-label {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.2px;
  color: #708ea8;
  padding: 16px 12px 6px;
}
.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.mini-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.mini-user strong { display: block; font-size: 12.5px; color: #ffffff; }
.mini-user small { color: #9bb5cf; font-size: 11px; }
.mini-user-info { min-width: 0; flex: 1; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #e0edfc;
  color: var(--navy);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}
.link-button {
  border: 0;
  background: none;
  color: #9bb5cf;
  padding: 3px 0;
  font-size: 12px;
  font-weight: 550;
  transition: color 0.15s;
}
.link-button:hover { color: #ffffff; }
.link-button.logout-btn { color: #fca5a5; }
.link-button.logout-btn:hover { color: #ffffff; }

/* Topbar & Main */
.main-wrap { margin-left: 240px; min-height: 100vh; }
.topbar {
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-logo {
  display: none;
  height: 28px;
  width: auto;
  max-width: 38px;
  object-fit: contain;
  flex: 0 0 auto;
}
.topbar-title {
  font-weight: 700;
  color: #1e3a5a;
  font-size: 14px;
  letter-spacing: -0.1px;
  line-height: 1.25;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: #334e68;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px #d1fae5;
}
.page-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 32px 100px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
}
.app-footer {
  margin-top: auto;
  padding-top: 36px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  border-top: 1px solid var(--line);
}
.footer-desktop { display: block; }
.footer-mobile { display: none; }
.mobile-only { display: none; }

/* Page Header & Titles */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-head h1, .page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.22;
  letter-spacing: -0.5px;
  font-weight: 750;
  color: var(--ink);
}
.page-head p, .page-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  max-width: 760px;
  font-size: 13.5px;
  line-height: 1.5;
}
.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
  font-size: 13.5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn .btn-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
  display: block;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 14px rgba(29, 104, 224, 0.22);
}
.btn-primary:hover {
  background: var(--blue-hover);
  box-shadow: 0 6px 18px rgba(29, 104, 224, 0.3);
}
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.btn-soft {
  background: var(--blue-2);
  color: var(--blue);
  border-color: var(--blue-border);
}
.btn-soft:hover {
  background: #e2eeff;
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecdd3;
}
.btn-danger:hover {
  background: #ffe4e6;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--line-subtle);
  color: var(--ink);
}
.btn-sm {
  min-height: 34px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12.5px;
}
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-button:hover { background: #f1f5f9; }

/* Grid */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease;
}
.card-pad { padding: 20px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title h2, .card-title h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
  color: var(--ink);
}
.card-title small { font-weight: 550; }

/* Metric Cards */
.metric {
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.metric:after {
  content: "";
  position: absolute;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--blue-2);
  right: -25px;
  top: -28px;
  opacity: 0.7;
}
.metric-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 650;
}
.metric-value {
  font-size: 28px;
  font-weight: 850;
  margin: 6px 0 4px;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.metric-foot { font-size: 12px; color: var(--muted); }
.metric-ok .metric-value { color: var(--ok); }

/* Platform Card */
.platform-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.platform-card-readonly {
  cursor: default;
}
.platform-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.platform-title-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.platform-title-row strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.platform-view-link {
  font-size: 12px;
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}
.platform-view-link:hover {
  text-decoration: underline;
}
.platform-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue-2);
  display: grid;
  place-items: center;
  font-size: 19px;
  color: var(--blue);
  flex-shrink: 0;
}
.platform-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  display: block;
}
.platform-card .platform-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}
.platform-count {
  font-size: 26px;
  font-weight: 850;
  line-height: 1.1;
  margin: 0;
  color: var(--ink);
}
.platform-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
}
.platform-card-actions form {
  display: inline-block;
  margin: 0;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
  color: #475569;
}
.status-pill.ok { background: var(--ok-bg); color: var(--ok); }
.status-pill.warn { background: var(--warn-bg); color: var(--warn); }
.status-pill.blue { background: var(--blue-2); color: var(--blue); }
.status-pill.danger { background: var(--danger-bg); color: var(--danger); }
.status-pill.gray { background: #f1f5f9; color: #64748b; }

/* Content Row & List */
.section-gap { margin-top: 20px; }
.list-stack { display: flex; flex-direction: column; gap: 10px; }
.content-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: all 0.15s ease;
}
.content-row:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 16px rgba(29, 104, 224, 0.08);
}
.row-arrow {
  color: var(--muted);
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
  align-self: center;
  transition: color 0.15s ease;
}
.content-row:hover .row-arrow {
  color: var(--blue);
}
.summary-icon {
  color: var(--muted);
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.15s ease;
}
details[open] > summary .summary-icon {
  transform: rotate(45deg);
  color: var(--blue);
}
.content-row-main { min-width: 0; flex: 1; }
.content-row h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.35;
  color: var(--ink);
}
.content-meta { display: flex; gap: 7px; flex-wrap: wrap; }
.meta-chip {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 650;
}
.content-summary {
  margin: 8px 0 0;
  color: #556980;
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Empty State */
.empty-state { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--blue-2);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  color: var(--blue);
  font-size: 22px;
  font-weight: 700;
}
.empty-icon svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  stroke-width: 2;
  display: block;
}
.empty-state h3 { color: var(--ink); margin: 8px 0 4px; font-size: 16px; }

/* Forms & Fields */
.form-card { padding: 22px; }
.form-section { margin-bottom: 24px; }
.form-section:last-child { margin-bottom: 0; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-heading h2 { font-size: 16.5px; font-weight: 750; margin: 0; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 700; color: #263b56; }
.req { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid #d1d9e4;
  background: #fff;
  border-radius: 10px;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  min-height: 42px;
  font-size: 13.5px;
  transition: border 0.15s, box-shadow 0.15s;
}
.field input:hover, .field select:hover, .field textarea:hover {
  border-color: #94a3b8;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(29, 104, 224, 0.14);
}
.field small { line-height: 1.4; color: var(--muted); font-size: 12px; }
.field-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.field-password-wrap input {
  padding-right: 44px;
}
.password-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.password-toggle-btn:hover {
  color: var(--navy);
  background: rgba(14, 39, 68, 0.06);
}
.password-toggle-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.password-toggle-btn svg {
  display: block;
}
.password-toggle-btn .eye-show {
  display: block;
}
.password-toggle-btn .eye-hide {
  display: none;
}
.password-toggle-btn.is-visible .eye-show {
  display: none;
}
.password-toggle-btn.is-visible .eye-hide {
  display: block;
}
.validation, .field-validation-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}
.validation ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.validation li {
  margin: 2px 0;
}
.validation:empty,
.validation-summary-valid,
.field-validation-valid {
  display: none !important;
}
.input-validation-error { border-color: #fca5a5 !important; }
.field-check { display: flex; align-items: center; gap: 9px; min-height: 42px; font-size: 13.5px; font-weight: 550; }
.field-check input { width: 17px; height: 17px; border-radius: 4px; accent-color: var(--blue); }
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* Filters & Toolbars */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-bar .field { min-width: 160px; }
.filter-bar .grow { flex: 1; min-width: 220px; }
.filter-bar input, .filter-bar select { min-height: 38px; padding: 8px 11px; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Tables */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: #fff;
}
.data-table th {
  background: #f8fafc;
  color: #556980;
  text-align: left;
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #f9fbfe; }

/* Report Cards */
.report-card {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: all 0.15s ease;
}
.report-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 16px rgba(29, 104, 224, 0.08);
}
.report-card-open {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.report-delete-form { padding-right: 14px; flex: 0 0 auto; }
.report-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--blue-2);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 850;
  font-size: 15px;
  flex-shrink: 0;
}
.report-badge svg,
.report-badge-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  display: block;
}
.report-main { flex: 1; min-width: 0; }
.report-main h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--ink); }
.report-main p { margin: 0; color: var(--muted); font-size: 12.5px; }
.report-side { text-align: right; }
.report-side small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); }

/* Callout & Tabs */
.callout {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #eef5ff;
  border: 1px solid #d4e3fb;
  color: #245eb9;
  font-size: 13px;
  line-height: 1.5;
}
.callout.warn { background: #fff8e8; border-color: #ffe3a7; color: #835a08; }
.callout.ok { background: #edf9f4; border-color: #ccebdd; color: #176a4d; }

.tabs { display: flex; gap: 6px; overflow: auto; padding-bottom: 4px; }
.tab {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 650;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.15s ease;
}
.tab:hover { background: #f8fafc; color: var(--ink); }
.tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.check-card {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 550;
}
.check-card input { width: 16px; height: 16px; accent-color: var(--blue); }

/* Paper View for Reports */
.paper-wrap {
  background: #dfe6ee;
  border-radius: 16px;
  padding: 22px;
  overflow: auto;
}
.paper {
  width: 210mm;
  max-width: none;
  min-height: 297mm;
  background: #fff;
  margin: 0 auto;
  padding: 20mm 20mm 18mm;
  box-shadow: 0 12px 28px rgba(17, 42, 72, 0.14);
  font-family: "Times New Roman", serif;
  font-size: 13pt;
  color: #111;
  box-sizing: border-box;
}
.paper p { font-size: 13pt; line-height: 1; margin: 0; }
.paper .data-table { font-family: "Times New Roman", serif; min-width: 0; width: 100%; border-collapse: collapse; }
.paper .data-table th, .paper .data-table td {
  font-size: 13pt;
  color: #111;
  border: 1px solid #666;
  padding: 3pt 5pt;
  vertical-align: top;
}
.paper .data-table th { background: #fff; text-transform: none; letter-spacing: 0; text-align: center; font-weight: 700; }
.manual-block { margin: 0; }
.manual-label { display: none; }
.preline { white-space: pre-line; }
.preview-block { margin: 0; }
.preview-header-grid, .preview-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 14mm;
  row-gap: 0;
  margin: 0;
}
.preview-header-grid { margin-bottom: 8pt; }
.preview-footer-grid { margin-top: 10pt; }
.preview-grid-cell { min-width: 0; }
.preview-grid-cell.full { grid-column: 1 / -1; }
.preview-data { margin: 6pt 0 8pt; }
.preview-intro { margin: 0 0 4pt; }
.preview-word-note {
  font-family: Inter, -apple-system, sans-serif;
  font-size: 11.5px;
  color: #6d7c91;
  margin: 0 0 10px;
  text-align: center;
}

/* ==================================================
   LOGIN PAGE
   ================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(440px, 0.85fr);
  background: #ffffff;
}
.login-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px 64px;
  color: #ffffff;
  background-color: #0b2440;
}
.login-visual-bg {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(145deg, rgba(8, 26, 47, 0.48) 0%, rgba(13, 39, 68, 0.40) 60%, rgba(18, 64, 105, 0.35) 100%), url('/images/login_bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.login-visual-overlay {
  display: none;
}
.login-visual-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.login-logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.login-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.login-brand strong {
  font-size: 26px;
  font-weight: 850;
  letter-spacing: 0.5px;
  display: block;
  line-height: 1.1;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.login-brand span {
  color: #e6f0fa;
  font-size: 13px;
  display: block;
  margin-top: 3px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.login-copy {
  max-width: 540px;
  margin: 36px 0;
}
.login-copy h1 {
  font-size: 38px;
  font-weight: 850;
  line-height: 1.18;
  letter-spacing: -0.8px;
  margin: 0 0 16px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
.login-copy p {
  font-size: 15.5px;
  color: #f1f6fc;
  line-height: 1.65;
  margin: 0 0 24px;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}
.login-features {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.login-features span {
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(7, 24, 43, 0.52);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.login-org {
  font-size: 13px;
  color: #e6f0fa;
  font-weight: 550;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.login-mobile-copyright {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
  line-height: 1.4;
}
.login-form-wrap {
  display: grid;
  place-items: center;
  padding: 40px;
  background: radial-gradient(circle at 80% 20%, #f0f6ff, transparent 40%), #ffffff;
}
.login-card {
  width: min(400px, 100%);
}
.login-form-header {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-mobile-logo-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #ffffff;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(12, 38, 71, 0.1);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.login-mobile-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.login-form-brand strong {
  font-size: 18px;
  font-weight: 850;
  color: var(--navy);
  display: block;
}
.login-form-brand small {
  font-size: 12px;
  color: var(--muted);
  display: block;
}
.login-card h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 6px;
  color: var(--ink);
}
.login-card > p {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 14px;
}
.login-card .field { margin-bottom: 14px; }
.login-button {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
  font-size: 14.5px;
}

/* Toast */
.toast {
  position: fixed;
  right: 28px;
  top: 80px;
  z-index: 100;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 700;
  animation: toast-in 0.2s ease;
  background: #fff;
}
.toast-success { border: 1px solid #c8ebdb; color: var(--ok); }
.toast-error { border: 1px solid #ffd1d5; color: var(--danger); }
@keyframes toast-in {
  from { transform: translateY(-7px); opacity: 0; }
}

/* Catalogs */
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.catalog-card { padding: 18px; }
.catalog-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 13px;
  border: 1px solid var(--line-subtle);
}
.catalog-item.inactive { opacity: 0.52; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input, .inline-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 120px;
  flex: 1;
}

.mobile-cards { display: none; }
.desktop-table { display: block; }
.sticky-mobile-actions { display: none; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-grid { grid-template-columns: 1fr; }
  .page-container { padding-left: 22px; padding-right: 22px; }
}

@media (min-width: 768px) and (max-width: 960px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(84vw, 300px);
    z-index: 70;
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 21, 38, 0.48);
    z-index: 60;
  }
  .drawer-backdrop.open { display: block; }
  .main-wrap { margin-left: 0; }
  .mobile-only { display: flex; }
  .bottom-nav { display: none; }
  .topbar-logo {
    display: block;
    height: 30px;
  }
  .page-container { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 767px) {
  body { padding-bottom: 76px; }
  .mobile-only { display: flex; }
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(84vw, 300px);
    z-index: 70;
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 21, 38, 0.48);
    z-index: 60;
  }
  .drawer-backdrop.open { display: block; }
  .main-wrap { margin-left: 0; }
  .topbar {
    min-height: 56px;
    height: auto;
    padding: 8px 14px;
    align-items: center;
  }
  .topbar-left {
    width: 100%;
    min-width: 0;
  }
  .topbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-width: 0;
  }
  .topbar-logo {
    display: block;
    height: 28px;
    width: auto;
    max-width: 36px;
    object-fit: contain;
    flex: 0 0 auto;
  }
  .topbar-title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    color: #1e3a5a;
    white-space: normal;
    word-break: break-word;
    flex: 1;
    min-width: 0;
  }
  .topbar-user { display: none; }
  .page-container { padding: 18px 14px 100px; }
  .page-head { flex-direction: column; margin-bottom: 16px; }
  .page-head h1, .page-title {
    font-size: 24px;
    line-height: 1.25;
    letter-spacing: -0.3px;
    font-weight: 750;
  }
  .page-head p, .page-subtitle {
    font-size: 13px;
    margin-top: 4px;
  }
  .head-actions { width: 100%; justify-content: stretch; }
  .head-actions .btn { flex: 1; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .card { border-radius: var(--radius); }
  .card-pad, .form-card { padding: 16px; }
  .platform-card { padding: 14px; }
  .metric { padding: 15px; }
  .form-grid { grid-template-columns: 1fr; gap: 13px; }
  .field.full { grid-column: auto; }
  .form-actions { display: none; }
  .sticky-mobile-actions {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 68px;
    z-index: 35;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
    gap: 9px;
  }
  .sticky-mobile-actions .btn { flex: 1; }
  .bottom-nav {
    position: fixed;
    z-index: 55;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 5px 8px max(5px, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 20px rgba(15, 45, 80, 0.07);
  }
  .bottom-nav a, .bottom-nav button {
    border: 0;
    background: transparent;
    color: #61758e;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    font-size: 18px;
  }
  .bottom-nav .nav-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    color: #61758e;
    display: block;
    transition: color 0.15s, stroke 0.15s;
  }
  .bottom-nav small { font-size: 10px; color: inherit; font-weight: 600; }
  .bottom-nav a.active { color: var(--blue); font-weight: 750; }
  .bottom-nav a.active .nav-icon { color: var(--blue); }
  .bottom-nav .bottom-add {
    color: #fff;
    background: var(--blue);
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 16px;
    transform: translateY(-10px);
    box-shadow: 0 8px 18px rgba(29, 104, 224, 0.28);
  }
  .bottom-nav .bottom-add .nav-icon {
    width: 22px;
    height: 22px;
    color: #ffffff;
    stroke: #ffffff;
  }
  .bottom-nav .bottom-add small { display: none; }
  .filter-bar { align-items: stretch; }
  .filter-bar .field, .filter-bar .grow { min-width: 100%; }
  .filter-bar .btn { width: 100%; }
  .desktop-table { display: none; }
  .mobile-cards { display: flex; flex-direction: column; gap: 10px; }
  .content-row { padding: 13px; }
  .row-actions { flex-direction: column; }
  .content-summary { -webkit-line-clamp: 3; }
  .paper-wrap { padding: 8px; border-radius: 12px; }
  .paper { padding: 16mm 14mm; min-height: 297mm; }
  .paper .table-wrap { overflow: auto; }
  .paper .data-table { min-width: 600px; }
  .check-grid { grid-template-columns: 1fr; }
  .report-card { align-items: stretch; flex-direction: column; gap: 0; }
  .report-card-open { align-items: flex-start; padding: 14px; }
  .report-delete-form { padding: 0 14px 14px; }
  .report-delete-form .btn { width: 100%; }
  .report-side { display: none; }
  .tabs { margin-left: -2px; margin-right: -2px; }
  
  /* Mobile Login */
  .login-page {
    display: block;
    background: linear-gradient(160deg, #eef5ff, #fff 38%);
  }
  .login-visual { display: none; }
  .login-form-wrap {
    min-height: 100vh;
    padding: 32px 20px 48px;
    background: transparent;
  }
  .login-card { padding-bottom: 20px; }
  .login-form-header { display: flex; }
  .toast { top: 66px; left: 14px; right: 14px; text-align: center; }
  .catalog-grid { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; }
  .inline-form input, .inline-form select { width: 100%; }
  .mobile-full { width: 100%; }
  .app-footer {
    margin-top: 32px;
    padding-top: 16px;
    text-align: center;
    font-size: 12px;
  }
  .footer-desktop { display: none; }
  .footer-mobile { display: block; }
  .login-mobile-copyright { display: block; }
}

@media (max-width: 390px) {
  .topbar-logo { height: 26px; }
  .topbar-title { font-size: 12px; }
  .page-head h1, .page-title { font-size: 21px; }
  .platform-count { font-size: 23px; }
  .btn { padding-left: 12px; padding-right: 12px; }
}

.mb-18 { margin-bottom: 18px; }
.text-center { text-align: center !important; }
.signature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 30px; }
.muted-copy { color: var(--muted); line-height: 1.6; }
.justify-start { justify-content: flex-start; }
.mt-12 { margin-top: 12px; }

@media (max-width: 767px) {
  .signature-grid { grid-template-columns: 1fr; gap: 8px; }
}

.builder-json { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
.manual-builder { display: flex; flex-direction: column; gap: 10px; }
.builder-row {
  display: grid;
  grid-template-columns: 1.05fr 1.5fr 1fr 1fr auto;
  gap: 9px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbfd;
}
.builder-row .field { gap: 4px; }
.builder-row .field label { font-size: 11px; color: var(--muted); }
.builder-row input, .builder-row select { min-height: 38px; padding: 8px 9px; }
.builder-extra { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

@media (max-width: 900px) {
  .builder-row { grid-template-columns: 1fr 1fr; }
  .builder-row > .btn { align-self: end; }
  .builder-extra { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
  .builder-row, .builder-extra { grid-template-columns: 1fr; }
  .builder-row > .btn { width: 100%; }
}

/* V2 - Word template management */
.upload-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
}
.template-token-box { display: grid; gap: 8px; }
.token-list { display: flex; flex-wrap: wrap; gap: 7px; }
.token-list code, .template-help code {
  background: #eef4ff;
  color: #174ea6;
  border: 1px solid #dbe7ff;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.82rem;
}
.template-help {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
}
.template-help p { margin: 6px 0; color: #475569; }

/* V3 - structural Word blocks */
.block-preview-list { display: grid; gap: 10px; }
.block-preview-item {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.block-preview-item b { font-size: 13px; }
.block-preview-item small { font-size: 11px; }
.block-preview-item span {
  white-space: pre-line;
  color: #40536b;
  font-size: 12px;
  line-height: 1.45;
  max-height: 92px;
  overflow: auto;
}
.notice-soft {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f1f6ff;
  color: #315b97;
  border: 1px solid #dce9ff;
  font-size: 12px;
}
.report-block-stack { display: grid; gap: 14px; }
.report-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}
.report-block h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.report-block .form-grid { margin-top: 0; }

/* V4 Rich Word Engine */
.rich-word-editor {
  border: 1px solid #d8e1ef;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 7px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  scrollbar-width: thin;
}
.rich-toolbar button, .rich-toolbar select {
  flex: 0 0 auto;
  height: 34px;
  min-height: 34px;
  border: 1px solid #d7dfeb;
  border-radius: 8px;
  background: #fff;
  padding: 4px 7px;
  color: #19324f;
  font-size: 0.86rem;
}
.rich-toolbar button { width: 34px; min-width: 34px; padding: 3px; }
.rich-toolbar [data-rich-font] { width: 150px; }
.rich-toolbar [data-rich-size] { width: 62px; }
.rich-toolbar [data-rich-line] { width: 92px; }
.rich-toolbar [data-rich-before], .rich-toolbar [data-rich-after] { width: 90px; }
.rich-toolbar [data-rich-first-line] { width: 112px; }
.toolbar-sep { flex: 0 0 1px; width: 1px; height: 22px; background: #d8e0eb; margin: 0 2px; }
.rich-surface {
  min-height: 135px;
  padding: 16px 18px;
  font-family: 'Times New Roman', serif;
  font-size: 13pt;
  line-height: 1;
  outline: none;
  background: #fff;
  color: #111;
}
.rich-surface p { margin: 0; min-height: 1.15em; }
.rich-surface p:last-child { margin-bottom: 0; }
.rich-surface:focus { box-shadow: inset 0 0 0 2px rgba(29, 104, 224, 0.14); }
.rich-help {
  padding: 7px 12px;
  background: #fbfcfe;
  border-top: 1px solid #edf1f6;
  font-size: 0.78rem;
  color: #6b7a90;
}
.template-rich-host { display: grid; gap: 14px; margin-top: 14px; }
.template-rich-card {
  border: 1px solid #e0e6ef;
  border-radius: 12px;
  padding: 12px;
  background: #fafbfd;
}
.template-rich-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 9px;
}
.template-rich-card-head small { color: #738096; }
.rich-preview { font-family: 'Times New Roman', serif; font-size: 13pt; }
.rich-preview p { margin: 0; min-height: 1em; }
.rich-preview span { white-space: pre-wrap; }

@media (max-width: 767px) {
  .rich-toolbar { gap: 3px; padding: 5px; }
  .rich-toolbar select { max-width: none; }
  .rich-surface { padding: 13px; font-size: 13pt; min-height: 160px; }
  .template-rich-card-head { align-items: flex-start; flex-direction: column; }
}

/* V7 - template sync and safer template editing */
.word-sync-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.word-sync-live { display: grid; gap: 10px; padding-top: 4px; }
.word-sync-live .block-preview-list { margin-top: 2px; }

@media (max-width: 767px) {
  .word-sync-actions { align-items: stretch; flex-direction: column; }
  .word-sync-actions .btn { width: 100%; }
}

/* User Administration & Permissions */
.platform-chip-list { display: flex; gap: 5px; flex-wrap: wrap; }
.user-list-mobile { display: none; }
.user-table { min-width: 940px; }
.user-table td { vertical-align: middle; }
.user-table td:last-child { white-space: nowrap; }
.user-filter-bar .field { min-width: 145px; }
.permission-editor { max-width: 900px; }
.permission-check {
  min-height: 70px;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
}
.permission-check input { position: absolute; opacity: 0; pointer-events: none; }
.permission-check:has(input:checked) {
  border-color: #93c5fd;
  background: #f0f7ff;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}
.permission-check small { padding-left: 0; }
.permission-platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.permission-platform-grid .check-card { min-height: 46px; }
.permission-editor code {
  font-size: 11px;
  background: #edf2f8;
  padding: 2px 5px;
  border-radius: 5px;
}
.user-mobile-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.user-mobile-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.user-mobile-head strong, .user-mobile-head small { display: block; }
.user-mobile-card .btn { width: 100%; }
details.form-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}
details.form-card > summary::-webkit-details-marker { display: none; }
details.form-card > summary small { display: block; margin-top: 4px; font-weight: 400; }
details.form-card[open] > summary {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 767px) {
  .user-list-mobile { display: grid; gap: 10px; }
  .user-table-wrap { display: none; }
  .permission-platform-grid { grid-template-columns: 1fr; }
  .permission-check { min-height: 64px; }
  .user-filter-bar .field { min-width: 100%; }
}

/* Enhanced Catalogs */
.catalog-add-drawer {
  margin-bottom: 12px;
}
.catalog-add-drawer > summary {
  display: inline-flex;
  cursor: pointer;
  list-style: none;
}
.catalog-add-drawer > summary::-webkit-details-marker { display: none; }
.catalog-add-drawer[open] {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 8px;
}
.catalog-item.inactive {
  background: #f8fafc;
  opacity: 0.75;
}
.catalog-item-info {
  flex: 1;
  min-width: 0;
}
.catalog-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.catalog-popover {
  position: relative;
}
.catalog-popover > summary {
  list-style: none;
  cursor: pointer;
}
.catalog-popover > summary::-webkit-details-marker { display: none; }
.catalog-popover[open] .catalog-edit-form {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  width: 280px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(14, 39, 68, 0.15);
  padding: 14px;
}
.btn-ok {
  background: #10b981;
  color: #fff;
  border: 1px solid #10b981;
}
.btn-ok:hover {
  background: #059669;
}
.btn-danger {
  background: #ef4444;
  color: #fff;
  border: 1px solid #ef4444;
}
.btn-danger:hover {
  background: #dc2626;
}

/* User Security Section */
.user-edit-container {
  display: grid;
  gap: 20px;
}
.security-card {
  border-top: 3px solid #1d68e0;
}
.security-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 14px;
}
.security-block {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.security-block h3 {
  font-size: 15px;
  margin-bottom: 6px;
  color: #0e2744;
}
.status-box {
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-readonly {
  background: #f1f5f9;
  cursor: not-allowed;
  color: #64748b;
}

/* Audit Log Viewer */
.audit-filter-bar .field { min-width: 140px; }
.audit-table { min-width: 860px; }
.audit-table th { padding: 10px 12px; }
.audit-table td { padding: 10px 12px; vertical-align: middle; }
.audit-time { white-space: nowrap; font-size: 12px; color: #64748b; font-variant-numeric: tabular-nums; }
.audit-detail { font-size: 12.5px; word-break: break-word; }
.audit-list-mobile { display: none; }
.audit-mobile-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.audit-mobile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.audit-mobile-body {
  font-size: 13px;
  display: grid;
  gap: 4px;
}
.audit-mobile-detail {
  color: #334155;
}
.audit-mobile-ip {
  color: #94a3b8;
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pagination-info {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

@media (max-width: 767px) {
  .security-grid { grid-template-columns: 1fr; }
  .audit-table-wrap { display: none; }
  .audit-list-mobile { display: grid; gap: 10px; }
  .audit-filter-bar .field { min-width: 100%; }
}

.is-hidden { display: none !important; }
.check-card.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.callout-subtle {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* Auth Required / Change Password Required Focus Shell */
.auth-required-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.auth-required-topbar {
  background: #0e2744;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  color: #fff;
}
.auth-required-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 20px;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
}
.auth-required-card {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  padding: 28px 24px;
  border: 1px solid var(--line);
}
.auth-required-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.auth-required-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.auth-required-head h2 {
  font-size: 18px;
  font-weight: 750;
  color: var(--ink);
  margin: 0 0 4px;
}
.auth-required-head p {
  font-size: 13px;
  margin: 0;
  line-height: 1.4;
  color: var(--muted);
}
@media (max-width: 640px) {
  .btn-full-mobile {
    width: 100%;
  }
}

.divider-subtle {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.alert-banner {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-banner.info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.alert-banner.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

/* Grid cell positions for report header/footer */
.col-1 { grid-column: 1; }
.col-2 { grid-column: 2; }
.col-3 { grid-column: 3; }
.col-4 { grid-column: 4; }
.row-1 { grid-row: 1; }
.row-2 { grid-row: 2; }
.row-3 { grid-row: 3; }
.row-4 { grid-row: 4; }
.report-print-title {
  font-size: 16pt;
  font-weight: 700;
  margin-top: 8pt;
  margin-bottom: 4pt;
}

/* Print page dedicated styles */
.print-page-body {
  background: #f1f5f9;
  color: #111827;
  margin: 0;
  padding: 0;
  font-family: 'Times New Roman', Times, serif;
}

.print-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 39, 68, 0.95);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.print-toolbar-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.print-toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.print-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.print-paper-wrap {
  padding: 24px 16px;
  display: flex;
  justify-content: center;
}

.print-paper {
  background: #fff;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 15mm 20mm 20mm;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  font-size: 13pt;
  line-height: 1.35;
  color: #000;
}

.print-paper .table-wrap {
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10pt;
  margin-bottom: 10pt;
}

.print-table th, .print-table td {
  border: 1px solid #000;
  padding: 5pt 7pt;
  font-size: 11pt;
}

.print-table th {
  background: #f1f5f9;
  font-weight: 700;
  text-align: center;
}

.print-table .col-stt {
  width: 36px;
  max-width: 42px;
  text-align: center;
  white-space: nowrap;
}

@page {
  size: A4 portrait;
  margin: 15mm 12mm 15mm 15mm;
}

@media print {
  /* 1. Global Print Reset & Strict Black & White Setup */
  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    -webkit-box-shadow: none !important;
  }

  /* 2. Hide Non-Print Elements & Scrollbars Completely */
  .no-print {
    display: none !important;
  }

  html,
  body,
  .print-page-body,
  .print-paper-wrap,
  .print-paper,
  .preview-data,
  .table-wrap,
  .print-table-wrap {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  *::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  /* 3. Paper & Body Reset: Pure White, Black Text */
  body.print-page-body {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .print-paper-wrap {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    background: transparent !important;
  }

  .print-paper {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 13pt;
    line-height: 1.35;
  }

  /* 4. Table Container: Full Width, No Outer Box/Borders/Scrollbar */
  .table-wrap,
  .print-table-wrap {
    overflow: visible !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 5. Pure Black & White Data Table - Fit Width A4 */
  .print-table,
  .data-table.print-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    margin: 8pt 0 12pt !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
    page-break-inside: auto !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .print-table thead {
    display: table-header-group !important;
  }

  .print-table tfoot {
    display: table-footer-group !important;
  }

  .print-table tr {
    page-break-inside: avoid !important;
    page-break-after: auto !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
  }

  /* 6. Header Cells: White Background, Bold Black Text, Solid Black Border */
  .print-table th,
  .data-table.print-table th {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    font-weight: 700 !important;
    text-align: center !important;
    border: 1px solid #000000 !important;
    padding: 5pt 6pt !important;
    font-size: 10.5pt !important;
    line-height: 1.3 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 7. Body Cells: Pure White, Black Text, Thin Black Border, No Stripes */
  .print-table td,
  .data-table.print-table td {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
    padding: 5pt 6pt !important;
    font-size: 10.5pt !important;
    line-height: 1.3 !important;
    vertical-align: top !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* STT column compact */
  .print-table .col-stt,
  .data-table.print-table .col-stt {
    width: 36px !important;
    max-width: 42px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  /* Ensure text-center stays centered */
  .print-table td.text-center,
  .data-table.print-table td.text-center {
    text-align: center !important;
  }

  /* Remove any zebra stripe, hover highlight, or badge background */
  .print-table tr:hover td,
  .data-table.print-table tr:hover td,
  .print-table tr:nth-child(even) td,
  .data-table.print-table tr:nth-child(even) td,
  .print-table tr:nth-child(odd) td,
  .data-table.print-table tr:nth-child(odd) td {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  .status-pill,
  .badge,
  .tag {
    background: transparent !important;
    background-color: transparent !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
  }

  /* Page break rules */
  .preview-block {
    page-break-inside: avoid !important;
  }
}

/* Modal Dialog & Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 39, 68, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 16px;
  animation: modalFadeIn 0.18s ease-out;
}
.modal-backdrop.is-hidden {
  display: none !important;
}
.modal-dialog {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 20px 45px rgba(12, 38, 71, 0.22), 0 4px 12px rgba(12, 38, 71, 0.08);
  border: 1px solid var(--line);
  overflow: hidden;
  animation: modalSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-dialog.modal-md {
  max-width: 580px;
}
.modal-dialog form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-subtle);
  background: #ffffff;
  flex-shrink: 0;
}
.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.modal-close-btn:hover {
  background: #f1f5f9;
  color: var(--ink);
}
.modal-body {
  padding: 20px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-light);
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}
.modal-body p {
  margin: 0 0 12px;
}
.modal-body p:last-child {
  margin-bottom: 0;
}
.modal-body .modal-catalog-name {
  font-weight: 700;
  color: #b91c1c;
  word-break: break-word;
}
.modal-warning-text {
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--line-subtle);
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .modal-backdrop {
    padding: 16px;
  }
  .modal-dialog,
  .modal-dialog.modal-md {
    max-width: 100%;
    width: calc(100% - 32px);
    max-height: calc(100vh - 32px);
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
