:root {
  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d7dde5;
  --line-strong: #b9c3cf;
  --text: #17202c;
  --muted: #647084;
  --brand: #b42318;
  --brand-dark: #941b13;
  --green: #0f766e;
  --blue: #1d4ed8;
  --amber: #b45309;
  --sidebar-w: 292px;
  --sidebar-bg: #1f2933;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 28px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand); }

.etp-shell { min-height: 100vh; padding-left: var(--sidebar-w); }
.auth-shell { padding-left: 0; }
.etp-main { padding: 28px 0 44px; }
.etp-container { width: calc(100% - 44px); max-width: none; margin: 0 auto; }
.result-wide,
.profile-wide,
.pricegraph-wide { max-width: none; }
.stack { display: grid; gap: 14px; }

.mobile-topbar { display: none; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  color: #e5e7eb;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.10); }
.sidebar-logo { width: 42px; height: 42px; display: inline-grid; place-items: center; color: #fff; background: var(--brand); border-radius: 9px; text-decoration: none; font-size: 1.2rem; font-weight: 900; }
.sidebar-title { font-size: 1rem; font-weight: 900; letter-spacing: .04em; color: #fff; }
.sidebar-subtitle { margin-top: 2px; font-size: .78rem; color: #a8b3c4; }
.sidebar-status { display: flex; align-items: center; gap: 8px; margin: 18px 0; padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,.06); color: #d5dde8; font-weight: 750; }
.sidebar-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sidebar-link { display: grid; gap: 2px; padding: 12px; border-radius: 8px; color: #dbe3ee; text-decoration: none; border: 1px solid transparent; }
.sidebar-link span { font-size: .96rem; font-weight: 850; white-space: nowrap; }
.sidebar-link small { color: #9aa7b8; font-weight: 650; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.08); }
.sidebar-link.active { color: #fff; background: var(--brand); border-color: rgba(255,255,255,.12); }
.sidebar-link.active small { color: rgba(255,255,255,.78); }
.sidebar-footer { margin-top: auto; padding-top: 18px; }
.mobile-brand { color: var(--text); text-decoration: none; font-weight: 900; white-space: nowrap; }

.page-head,
.result-hero,
.profile-hero,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.page-head,
.result-hero,
.profile-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 20px 22px;
}
.page-head h1,
.page-head h2,
.page-head h3,
.result-hero h1,
.profile-hero h1 { margin: 0; font-size: 1.34rem; line-height: 1.25; font-weight: 850; letter-spacing: 0; }
.page-subtitle,
.panel-note { margin-top: 5px; color: var(--muted); }
.eyebrow { margin-bottom: 6px; color: var(--brand); font-size: .76rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.panel { overflow: hidden; }
.panel-body { padding: 16px; }
.panel-header { min-height: 56px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-title,
.section-title { margin: 0; color: #263445; font-size: .92rem; font-weight: 850; letter-spacing: .03em; text-transform: uppercase; }

.system-badge,
.badge-soft { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface-soft); color: #334155; border-radius: 999px; padding: .34rem .62rem; font-weight: 750; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.status-dot.warn { background: var(--amber); }

.btn { border-radius: 7px; font-weight: 800; white-space: nowrap; }
.btn-primary,
.btn-danger { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover,
.btn-danger:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-secondary { background: #334155; border-color: #334155; color: #fff; }
.btn-secondary:hover { background: #1f2937; border-color: #1f2937; color: #fff; }
.btn-outline-primary { color: var(--brand); border-color: #d7a19b; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-outline-secondary { color: #334155; border-color: #b9c3cf; }
.btn-outline-secondary:hover { background: #334155; border-color: #334155; color: #fff; }
.btn-warning { background: #f2c14e; border-color: #e6b23f; color: #2f2400; }
.btn-sm { padding: .33rem .58rem; }

.form-control,
.form-select,
.input-group-text { border-color: #cbd5e1; border-radius: 7px; }
.form-control:focus,
.form-select:focus { border-color: #8aa4c5; box-shadow: 0 0 0 .18rem rgba(29,78,216,.12); }
.input-group .form-control { min-width: 0; }
.alert { border-radius: 8px; border-width: 1px; }
.alert-info { background: #edf8f7; border-color: #b9e2dd; color: #134e4a; }
.alert-warning { background: #fff7e6; border-color: #f5d99a; color: #6b3d05; }
.alert-danger { background: #fff1f0; border-color: #fecaca; color: #7f1d1d; }

.table-panel { overflow: hidden; }
.auction-highlight { margin: 0 0 14px; border-color: #f0cf8a; background: #fff8e8; box-shadow: 0 14px 32px rgba(180,83,9,.12); }
.auction-highlight .panel-header { background: #fff3d6; border-bottom-color: #f0cf8a; }
.auction-highlight .panel-title { color: #7c2d12; }
.auction-highlight .list-row { border-top-color: #f4dba5; background: rgba(255,255,255,.48); }
.auction-highlight .list-row:hover { background: #fff; }
.table-responsive { max-width: 100%; scrollbar-width: thin; }
.table { margin-bottom: 0; --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .7rem .75rem; border-color: #e7ebf0; vertical-align: middle; }
.table thead th { background: #eef2f6; color: #3a4656; font-size: .74rem; font-weight: 850; text-transform: uppercase; letter-spacing: .035em; white-space: nowrap; border-bottom: 1px solid var(--line-strong); }
.table tbody tr:hover { background: #fbfcfd; }
.table-empty { color: var(--muted); text-align: center; padding: 34px 12px !important; }
.text-nowrap,
.table td.text-end,
.table th.text-end { white-space: nowrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card { padding: 15px 16px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); font-size: .76rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.metric-value { margin-top: 8px; color: var(--text); font-size: 1.55rem; line-height: 1; font-weight: 850; }
.dashboard-grid { display: grid; grid-template-columns: minmax(320px, 1.08fr) minmax(300px, .94fr) minmax(320px, .98fr); gap: 14px; align-items: stretch; margin-bottom: 14px; }
.dashboard-message { margin-bottom: 14px; }
.dashboard-chart-panel { margin-top: 0; }
.info-panel-body { max-height: 360px; overflow: auto; }
.license-panel { min-width: 0; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.list-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px 16px; color: var(--text); text-decoration: none; border-top: 1px solid #edf0f3; }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #fafbfc; color: var(--text); }
.period-chart { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding: 18px 16px 14px; min-height: 320px; }
.period-chart-yaxis { height: 260px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; color: var(--muted); font-size: .76rem; font-weight: 800; }
.period-chart-plot { min-width: 0; height: 300px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(58px, 1fr); gap: 12px; align-items: end; overflow-x: auto; padding: 0 2px 4px; border-left: 1px solid #dfe5ec; border-bottom: 1px solid #dfe5ec; background: repeating-linear-gradient(to top, transparent 0, transparent 78px, #edf0f3 79px, transparent 80px); }
.period-chart-item { min-width: 0; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.period-chart-bar-wrap { height: 260px; display: flex; align-items: end; justify-content: center; }
.period-chart-bar { width: min(100%, 52px); min-height: 4px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #d6473d 0%, #b42318 100%); position: relative; }
.period-chart-bar span { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); color: #fff; font-size: .72rem; font-weight: 850; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.period-chart-label { min-height: 34px; color: var(--muted); font-size: .72rem; font-weight: 800; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.info-list { display: grid; gap: 10px; margin: 0; }
.info-list dt { color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.info-list dd { margin: 2px 0 0; font-weight: 650; }
.license-check-summary { padding: 14px 16px; border-top: 1px solid #edf0f3; background: #fafbfc; }
.license-check-title { font-weight: 800; overflow-wrap: anywhere; }
.license-check-list { display: grid; border-top: 1px solid #edf0f3; }
.license-check-row { display: grid; gap: 8px; padding: 14px 16px; border-top: 1px solid #edf0f3; }
.license-check-row:first-child { border-top: 0; }
.license-check-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.license-type { font-weight: 800; color: var(--text); }
.license-status { max-width: 52%; padding: 3px 8px; border-radius: 999px; background: #eaf7ef; color: #177642; font-size: .76rem; font-weight: 850; text-align: right; overflow-wrap: anywhere; }
.license-number { font-weight: 750; overflow-wrap: anywhere; }
.license-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.license-meta dt { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.license-meta dd { margin: 1px 0 0; font-weight: 700; }
.license-authority { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.license-check-more { padding: 10px 16px; border-top: 1px solid #edf0f3; color: var(--muted); font-weight: 700; }
.empty-state { padding: 16px; color: var(--muted); }
.supplier-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-content: start; }
.supplier-summary.compact { grid-template-columns: 1fr; gap: 14px; }

.sticky-tools { position: sticky; top: 20px; z-index: 7; }
.auction-controls .panel-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.auction-pages { min-width: 0; overflow-x: auto; }
.auction-pages .pagination { flex-wrap: nowrap; }
.auction-row-own { --bs-table-bg: #edf8f3; }
.auction-row-other { --bs-table-bg: #fffaf0; }

.action-tabs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.result-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.result-warning { min-height: 96px; padding: 15px 16px; display: flex; flex-direction: column; justify-content: center; border-color: #f0cf8a; background: #fff8e8; }
.result-warning strong { color: #6b3d05; font-weight: 900; margin-bottom: 4px; }
.result-warning span { color: #78530f; }
.result-table .result-name { min-width: 340px; }

.profile-hero { align-items: stretch; }
.profile-hero h1 { max-width: 980px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.profile-meta span,
.profile-total { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 8px; }
.profile-meta span { padding: 6px 9px; color: #475569; font-weight: 750; }
.profile-total { min-width: 270px; padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; }
.profile-total span { color: var(--muted); font-size: .76rem; font-weight: 850; text-transform: uppercase; }
.profile-total strong { margin-top: 6px; font-size: 1.28rem; }
.profile-layout { display: grid; grid-template-columns: minmax(320px, 30%) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.profile-side { min-width: 0; display: flex; }
.profile-panel,
.profile-form-panel { width: 100%; min-width: 0; display: flex; flex-direction: column; }
.profile-facts { display: grid; }
.profile-facts > div { padding: 14px 16px; border-top: 1px solid #edf0f3; }
.profile-facts > div:first-child { border-top: 0; }
.profile-facts span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .73rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.profile-facts strong { display: block; color: var(--text); font-weight: 750; overflow-wrap: anywhere; }
.profile-form { flex: 1; padding: 18px; display: flex; flex-direction: column; }
.form-section-title { margin: 2px 0 12px; color: #334155; font-size: .82rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.form-section-title:not(:first-child) { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.profile-form .form-label { color: #475569; font-weight: 800; }
.profile-form .form-control { min-height: 42px; background: #fbfcfd; }
.info-callout { padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: #334155; }
.profile-notification-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.profile-notification-row strong { display: block; margin-top: 6px; color: var(--text); font-size: 1rem; }
.profile-actions { margin: auto -18px -18px; padding: 14px 18px; display: flex; justify-content: flex-end; gap: 10px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }

.price-chart-panel { margin-bottom: 14px; }
.price-chart-wrap { padding: 16px; }
.price-chart-wrap canvas { display: block; width: 100%; max-width: 100%; }

.auth-screen { max-width: 1180px; min-height: calc(100vh - 88px); display: grid; align-items: center; gap: 18px; margin-left: auto; margin-right: auto; }
.auth-login-screen { gap: 4px; }
.auth-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: stretch; }
.auth-visual { min-height: 430px; padding: 32px; border-radius: 8px; color: #fff; background: #222b36; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.auth-visual::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(180,35,24,.7), rgba(15,118,110,.48)); }
.auth-visual > * { position: relative; }
.auth-title { max-width: 800px; margin: 0; font-size: 2.6rem; line-height: 1.05; font-weight: 850; letter-spacing: 0; }
.auth-copy { max-width: 660px; color: rgba(255,255,255,.82); font-size: 1.05rem; }
.auth-card { padding: 26px; }
.auth-screen > .pharmcontrol-widget { grid-column: 1 / -1; }
.pharmcontrol-widget { display: grid; gap: 14px; margin-top: 0; padding: 20px; border: 1px solid rgba(207,216,229,.95); border-radius: 8px; background: #fff; box-shadow: 0 16px 38px rgba(23,32,51,.08); }
.pharmcontrol-widget-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.pharmcontrol-widget-top span { color: var(--brand); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.pharmcontrol-widget-top a { font-size: 13px; font-weight: 750; }
.pharmcontrol-widget h2 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 850; }
.pharmcontrol-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pharmcontrol-list { display: grid; gap: 8px; min-width: 0; }
.pharmcontrol-list-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.pharmcontrol-list-head strong { font-size: 15px; }
.pharmcontrol-list-head a { font-size: 13px; font-weight: 750; white-space: nowrap; }
.pharmcontrol-letter { display: block; min-height: 76px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); text-decoration: none; }
.pharmcontrol-letter:hover { background: #fff7f5; color: var(--text); text-decoration: none; }
.pharmcontrol-letter span { display: block; margin-bottom: 4px; color: #667085; font-size: 12px; font-weight: 750; }
.pharmcontrol-letter b { display: block; font-size: 13px; line-height: 1.32; }
.pharmcontrol-empty { padding: 12px; border: 1px dashed var(--line); border-radius: 8px; color: #667085; font-size: 13px; background: var(--surface-soft); }

.footer { width: 100%; padding: 16px 0; color: var(--muted); background: #fff; border-top: 1px solid var(--line); font-size: .88rem; }
.footer .etp-container { display: flex; justify-content: space-between; gap: 12px; }

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .license-panel { grid-column: 1 / -1; }
  .workspace-grid,
  .profile-layout,
  .result-summary { grid-template-columns: 1fr; }
  .profile-side,
  .profile-panel,
  .profile-form-panel { display: block; }
  .result-actions,
  .action-tabs { justify-content: flex-start; }
}
@media (max-width: 992px) {
  .etp-shell { padding-left: 0; }
  .app-sidebar { display: none; }
  .mobile-topbar { display: flex; background: #fff; border-bottom: 1px solid var(--line); }
  .mobile-topbar .etp-container { min-height: 58px; display: flex; align-items: center; gap: 12px; }
  .mobile-topbar .navbar-collapse { width: 100%; }
  .mobile-topbar .navbar-nav { padding-top: 12px; }
  .etp-container { width: calc(100% - 24px); }
  .page-head,
  .result-hero,
  .profile-hero { flex-direction: column; }
  .auth-grid { grid-template-columns: 1fr; }
  .auth-visual { min-height: 320px; }
  .auth-card { max-width: none; }
}
@media (max-width: 768px) {
  .dashboard-grid,
  .kpi-grid,
  .pharmcontrol-columns { grid-template-columns: 1fr; }
  .period-chart { grid-template-columns: 58px minmax(0, 1fr); padding: 14px 10px 12px; }
  .period-chart-yaxis { font-size: .68rem; }
  .period-chart-plot { grid-auto-columns: minmax(44px, 1fr); gap: 8px; }
  .period-chart-bar { width: min(100%, 38px); }
  .period-chart-bar span { display: none; }
  .supplier-summary { grid-template-columns: 1fr; gap: 12px; }
  .auction-controls .panel-body { grid-template-columns: 1fr; }
  .profile-total { min-width: 0; }
  .profile-notification-row { align-items: flex-start; flex-direction: column; }
  .profile-actions { flex-direction: column-reverse; }
  .profile-actions .btn { width: 100%; }
  .auth-title { font-size: 2rem; }
}
@media (max-width: 576px) {
  body { font-size: 13px; }
  .etp-container { width: calc(100% - 18px); }
  .etp-main { padding-top: 14px; }
  .page-head,
  .result-hero,
  .profile-hero,
  .panel-body,
  .panel-header,
  .metric-card,
  .auth-card { padding: 13px; }
  .list-row { flex-direction: column; gap: 4px; }
  .pharmcontrol-widget { padding: 16px; }
  .pharmcontrol-widget-top { display: grid; }
  .pharmcontrol-letter { min-height: auto; }
  .footer .etp-container { align-items: flex-start; flex-direction: column; }
}

/* 2026-06-03 UI polish after browser audit */
.page-head h1,
.profile-hero h1,
.result-hero h1,
.panel-title,
.list-row strong { overflow-wrap: anywhere; }
.page-head .btn,
.result-hero .btn,
.profile-hero .btn { align-self: flex-start; }
@media (max-width: 768px) {
  .page-head,
  .result-hero,
  .profile-hero { gap: 10px; }
  .page-head h1,
  .result-hero h1,
  .profile-hero h1 { font-size: 1.14rem; line-height: 1.28; }
  .page-subtitle,
  .panel-note { font-size: .9rem; line-height: 1.35; }
  .profile-meta { gap: 6px; }
  .profile-meta span { max-width: 100%; overflow-wrap: anywhere; }
  .profile-total { width: 100%; }
  .period-chart { grid-template-columns: 46px minmax(0, 1fr); overflow: hidden; }
  .period-chart-yaxis { width: 46px; }
  .period-chart-plot { grid-auto-columns: 38px; gap: 7px; contain: paint; }
  .period-chart-label { font-size: .66rem; }
}
@media (max-width: 576px) {
  .page-head .d-flex,
  .result-hero .d-flex,
  .profile-hero .d-flex { width: 100%; flex-wrap: wrap; }
  .page-head .btn,
  .result-hero .btn,
  .profile-hero .btn { min-height: 40px; }
  .profile-hero h1 { font-size: 1.04rem; }
  .auth-title { font-size: 1.72rem; }
  .auth-copy { font-size: .96rem; }
}
