:root {
  --navy: #075985;
  --navy-strong: #06456a;
  --blue-soft: #e8f3f8;
  --green: #22a06b;
  --green-soft: #e8f7f0;
  --amber: #d97706;
  --amber-soft: #fff6df;
  --red: #c2414b;
  --red-soft: #fff0f1;
  --ink: #18323f;
  --muted: #687b86;
  --line: #d9e2e7;
  --canvas: #f4f7fa;
  --surface: #ffffff;
  --shadow: 0 8px 24px rgba(24, 50, 63, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, strong { font-weight: 600; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 44%) 1fr;
  background: var(--surface);
}

.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  color: white;
  background: var(--navy);
}

.login-brand::after {
  content: "";
  position: absolute;
  inset: auto -10% -16% 24%;
  height: 48%;
  background: linear-gradient(135deg, transparent 0 20%, rgba(255,255,255,.09) 20% 24%, transparent 24% 38%, rgba(66,184,131,.55) 38% 43%, transparent 43%);
  transform: rotate(-5deg);
}

.brand-lockup { position: relative; z-index: 1; display: flex; gap: 14px; align-items: center; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 8px; background: white; color: var(--navy); font-weight: 600;
}
.brand-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: block;
  object-fit: contain;
}
.brand-lockup strong { display: block; font-size: 22px; }
.brand-lockup span { color: #bfe4d2; font-size: 13px; }
.brand-message { position: relative; z-index: 1; max-width: 500px; }
.brand-message h1 { margin: 0 0 18px; font-size: clamp(38px, 5vw, 68px); line-height: 1.02; letter-spacing: 0; }
.brand-message p { margin: 0; max-width: 430px; color: #cce3ee; font-size: 18px; line-height: 1.6; }
.brand-foot { position: relative; z-index: 1; color: #a9cddd; font-size: 13px; }

.login-panel { display: grid; place-items: center; padding: 36px; }
.login-card { width: min(460px, 100%); }
.company-label { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.company-logo {
  width: 48px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; color: var(--navy); font-weight: 600;
}
.company-label strong { display: block; font-size: 18px; }
.company-label span { color: var(--muted); font-size: 13px; }
.login-card h2 { margin: 0; font-size: 30px; }
.login-card > p { margin: 9px 0 28px; color: var(--muted); }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 7px;
  background: white; color: var(--ink); padding: 12px 13px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: #4b9bc2; box-shadow: 0 0 0 3px rgba(75,155,194,.14); }
.textarea { min-height: 88px; resize: vertical; }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 46px; }
.icon-inline {
  position: absolute; right: 7px; top: 6px; width: 36px; height: 36px; border: 0;
  background: transparent; color: var(--muted); font-size: 18px;
}
.check-line { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 22px; font-size: 13px; color: var(--muted); }
.check-line label { display: flex; align-items: center; gap: 8px; }
.check-line a { color: var(--navy); font-weight: 600; text-decoration: none; }

.btn {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 7px; padding: 10px 16px; font-weight: 600;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-strong); }
.btn-success { background: var(--green); color: white; }
.btn-secondary { background: white; border-color: var(--line); color: var(--ink); }
.btn-danger { background: white; border-color: #efb8bd; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { background: transparent; color: var(--navy); padding-inline: 8px; }
.btn-access { min-width: 104px; background: white; }
.btn-access.allowed { border-color: #84cbaa; color: #14744d; }
.btn-access.allowed:hover { background: var(--green-soft); border-color: var(--green); }
.btn-access.blocked { border-color: #efb8bd; color: var(--red); }
.btn-access.blocked:hover { background: var(--red-soft); border-color: var(--red); }
.btn-block { width: 100%; }
.demo-access { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.demo-access > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.demo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.demo-chip { border: 1px solid var(--line); background: var(--canvas); border-radius: 7px; padding: 9px; color: var(--ink); font-size: 12px; font-weight: 600; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 16px;
  display: flex; flex-direction: column; background: #063f61; color: white;
}
.sidebar .brand-lockup { padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.14); }
.sidebar .brand-mark, .sidebar .brand-logo { width: 44px; height: 44px; flex-basis: 44px; }
.nav-list { display: grid; gap: 5px; margin-top: 24px; }
.nav-button {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px;
  border: 0; border-radius: 7px; padding: 10px 12px; background: transparent;
  color: #c9e0eb; text-align: left; font-weight: 600;
}
.nav-button:hover, .nav-button.active { background: rgba(255,255,255,.12); color: white; }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.sidebar-user { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.14); }
.sidebar-user strong, .sidebar-user span { display: block; }
.sidebar-user span { margin-top: 3px; color: #a9cddd; font-size: 12px; }
.sidebar-user button { margin-top: 12px; width: 100%; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10; min-height: 72px; padding: 12px 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--navy);
  place-items: center;
  padding: 9px;
}
.menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 3px auto;
  border-radius: 2px;
  background: currentColor;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(7, 32, 45, .44);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.sidebar-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.page-title { margin: 0; font-size: 21px; }
.page-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.status-pill {
  display: inline-flex; gap: 7px; align-items: center; border-radius: 999px;
  padding: 7px 10px; background: var(--green-soft); color: #14744d; font-size: 12px; font-weight: 600;
}
.status-pill.offline { background: var(--amber-soft); color: #9a5a05; }
.icon-button {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--navy); font-size: 18px;
}
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; display: grid; place-items: center;
  border: 2px solid white; border-radius: 10px; background: var(--red); color: white; font-size: 10px; font-weight: 600;
}
.content { padding: 28px; max-width: 1500px; margin: 0 auto; }

.hero-band {
  display: flex; justify-content: space-between; gap: 20px; align-items: flex-end;
  margin-bottom: 24px; padding: 24px 28px; background: var(--navy); color: white;
}
.hero-band h2 { margin: 0 0 8px; font-size: 26px; }
.hero-band p { margin: 0; color: #cce3ee; }
.hero-meta { text-align: right; color: #cce3ee; font-size: 13px; }
.hero-meta strong { display: block; margin-top: 5px; color: white; font-size: 17px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-card, .panel, .action-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.metric-card { padding: 18px; min-height: 142px; }
.metric-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.metric-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; background: var(--blue-soft); color: var(--navy); font-size: 18px; }
.metric-value { margin-top: 16px; font-size: 27px; font-weight: 500; }
.metric-foot { margin-top: 7px; color: var(--muted); font-size: 12px; }
.positive { color: var(--green); }
.warning { color: var(--amber); }
.negative { color: var(--red); }

.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 28px 0 14px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel { padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-title { margin: 0 0 16px; font-size: 16px; }
.progress { height: 9px; overflow: hidden; border-radius: 5px; background: #e6ecef; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.progress.orange > span { background: #f39a4a; }
.progress-label { display: flex; justify-content: space-between; margin: 9px 0 5px; color: var(--muted); font-size: 12px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: white; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { background: #edf3f6; color: #4e6571; font-size: 11px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.rank { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: white; font-weight: 600; }
.rank-1 { background: #179567; }
.rank-2 { background: #54ad83; }
.rank-3 { background: #d5a535; }
.rank-other { background: #83949d; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 600; }
.tag-success { background: var(--green-soft); color: #14744d; }
.tag-warning { background: var(--amber-soft); color: #9a5a05; }
.tag-muted { background: #edf1f3; color: #5f727c; }
.tag-danger { background: var(--red-soft); color: var(--red); }

.filters { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)) auto; gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filter-actions { display: flex; gap: 8px; }

.form-section { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; background: white; overflow: hidden; }
.form-section-head { padding: 15px 18px; display: flex; justify-content: space-between; background: #edf3f6; }
.form-section-head h3 { margin: 0; font-size: 15px; }
.form-section-body { padding: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-section-body .field { margin: 0; }
.form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px;
  padding: 15px 18px; border: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -6px 18px rgba(24,50,63,.08);
}
.helper { color: var(--muted); font-size: 11px; line-height: 1.45; }

.chart { height: 220px; display: flex; align-items: flex-end; gap: 12px; padding: 18px 8px 4px; border-bottom: 1px solid var(--line); }
.bar-wrap { flex: 1; min-width: 28px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar { width: min(38px, 75%); min-height: 4px; border-radius: 5px 5px 0 0; background: var(--navy); }
.bar.secondary { background: var(--green); }
.bar-label { color: var(--muted); font-size: 10px; }

.action-card { padding: 20px; display: flex; align-items: center; gap: 15px; border-left: 4px solid var(--navy); }
.action-card h3 { margin: 0 0 5px; font-size: 15px; }
.action-card p { margin: 0; color: var(--muted); font-size: 12px; }
.action-card .metric-icon { flex: 0 0 auto; }
.action-card button { margin-left: auto; }

.notification-list { display: grid; gap: 10px; }
.notification {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: white;
}
.notification.unread { border-left: 4px solid var(--navy); }
.notification p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.notification time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.seller-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.calculator { width: min(390px, 100%); margin: 22px auto; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: var(--shadow); }
.calculator-history { min-height: 22px; padding: 6px 4px; color: var(--muted); text-align: right; font-size: 12px; }
.calculator-display { width: 100%; height: 72px; margin-bottom: 12px; padding: 10px 14px; border: 0; background: #edf3f6; color: var(--ink); text-align: right; font-size: 32px; font-weight: 500; }
.calculator-keys { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.calculator-keys button { min-height: 58px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); font-size: 18px; transition: .15s ease; }
.calculator-keys button:hover { background: var(--blue-soft); border-color: #8abbd1; }
.calculator-keys .operator { color: var(--navy); background: var(--blue-soft); }
.calculator-keys .equals { grid-column: span 2; background: var(--navy); color: white; border-color: var(--navy); }
.occurrence-form {
  padding: 18px;
  display: grid;
  grid-template-columns: 1.2fr .8fr 1.8fr auto;
  gap: 12px;
  align-items: end;
}
.occurrence-form .field { margin: 0; }
.occurrence-form-with-date { grid-template-columns: .7fr 1.1fr 1fr .55fr 1.4fr auto; }
.occurrence-helper { margin: -4px 18px 18px; }
.occurrence-history { padding: 0 18px 18px; }
.occurrence-pending td { background: #fff9e8; }
.occurrence-pending td:first-child { border-left: 4px solid var(--amber); }
.treatment-note { max-width: 280px; white-space: normal; color: var(--muted); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(7, 32, 45, .58);
}
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; border-radius: 8px; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { border: 0; background: transparent; font-size: 22px; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 20px; border-top: 1px solid var(--line); }
.toast {
  position: fixed; z-index: 200; right: 22px; bottom: 22px; max-width: 360px;
  padding: 13px 16px; border-radius: 7px; background: #18323f; color: white;
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.mobile-only { display: none; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .form-section-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .login-shell { display: block; background: white; }
  .login-brand { min-height: 210px; padding: 28px 24px; justify-content: flex-start; }
  .brand-message { margin-top: 34px; }
  .brand-message h1 { font-size: 34px; }
  .brand-message p { font-size: 14px; }
  .brand-foot { display: none; }
  .login-panel { padding: 28px 22px 42px; display: block; }
  .company-label { margin-bottom: 24px; }
  .demo-grid { grid-template-columns: 1fr; }

  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(310px, 86vw);
    height: 100dvh;
    padding: 22px 16px;
    display: flex;
    background: #063f61;
    border-top: 0;
    color: white;
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: 12px 0 34px rgba(7,32,45,.24);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand-lockup { display: flex; }
  .sidebar-user { display: block; }
  .nav-list { height: auto; margin-top: 22px; display: grid; gap: 5px; overflow: visible; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-button { min-width: 0; min-height: 44px; padding: 10px 12px; flex: initial; display: flex; place-items: initial; gap: 12px; color: #c9e0eb; font-size: 14px; text-align: left; }
  .nav-button:hover, .nav-button.active { background: rgba(255,255,255,.12); color: white; }
  .nav-icon { width: 22px; font-size: 17px; }
  .sidebar-overlay { display: block; }
  .menu-btn { display: block; }
  .topbar { min-height: 62px; padding: 10px 15px; z-index: 20; }
  .page-title { font-size: 18px; }
  .page-subtitle, .status-pill span { display: none; }
  .content { padding: 16px 14px 24px; }
  .hero-band { margin: -16px -14px 18px; padding: 22px 18px; align-items: flex-start; }
  .hero-band h2 { font-size: 21px; }
  .hero-meta { text-align: left; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid.mobile-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { min-height: 126px; padding: 15px; }
  .metric-value { font-size: 23px; }
  .section-head { align-items: flex-start; }
  .section-head .btn { padding: 9px 10px; }
  .filters { grid-template-columns: 1fr; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; }
  .form-section-body { grid-template-columns: 1fr; }
  .occurrence-form, .occurrence-form-with-date { grid-template-columns: 1fr; }
  .occurrence-helper { margin: -2px 18px 18px; }
  .form-actions { margin: 0 -14px -24px; padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
  .form-actions .btn { flex: 1; padding-inline: 8px; }
  .action-card { align-items: flex-start; }
  .action-card button { margin-left: 0; }
  .seller-card {
    grid-template-columns: auto 1fr;
    gap: 10px 12px;
  }
  .seller-card .metric-icon { width: 30px; height: 30px; font-size: 16px; }
  .seller-info { min-width: 0; }
  .seller-actions {
    grid-column: 2;
    justify-content: flex-start;
    gap: 7px;
  }
  .seller-actions .btn {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
  }
  .seller-actions .btn-access { min-width: 88px; }
  .top-actions .btn { display: none; }
  .mobile-only { display: inline-flex; }
}

@media print {
  .sidebar, .topbar, .form-actions, .btn, .icon-button { display: none !important; }
  .app-shell { display: block; }
  .content { max-width: none; padding: 0; }
  .panel, .metric-card { box-shadow: none; break-inside: avoid; }
  body { background: white; }
}
