:root {
  --gocmr-ink: #102c2a;
  --gocmr-deep: #0a3b35;
  --gocmr-green: #176b5b;
  --gocmr-green-2: #208a75;
  --gocmr-mint: #dff4eb;
  --gocmr-cream: #f6f7f3;
  --gocmr-line: #dfe6e2;
  --gocmr-sidebar: 256px;
  --tblr-primary: #176b5b;
  --tblr-primary-rgb: 23,107,91;
}

* { box-sizing: border-box; }
body { color: var(--gocmr-ink); background: var(--gocmr-cream); }
a { color: var(--gocmr-green); }
.btn-primary { --tblr-btn-bg: var(--gocmr-green); --tblr-btn-border-color: var(--gocmr-green); --tblr-btn-hover-bg: #10584b; --tblr-btn-hover-border-color: #10584b; }
.text-primary { color: var(--gocmr-green) !important; }
.skip-link { position: fixed; z-index: 1100; top: 8px; left: 8px; padding: 8px 12px; color: #fff; background: #000; border-radius: 6px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.eyebrow { font-size: .7rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; width: auto; object-fit: contain; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--gocmr-deep); background: #a6e9cf; border-radius: 11px; font-size: 1.4rem; }

/* Login */
.login-page { min-height: 100vh; background: #fff; }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(400px, 47%) 1fr; }
.login-story { position: relative; display: flex; flex-direction: column; min-height: 100vh; padding: clamp(2rem, 5vw, 4.75rem); overflow: hidden; color: white; background: var(--gocmr-deep); }
.login-story::before, .login-story::after { content: ""; position: absolute; border: 1px solid rgba(166,233,207,.14); border-radius: 50%; }
.login-story::before { width: 660px; height: 660px; right: -390px; bottom: -220px; }
.login-story::after { width: 460px; height: 460px; right: -245px; bottom: -120px; }
.story-copy { position: relative; z-index: 1; max-width: 640px; margin: auto 0 3rem; }
.story-copy .eyebrow { color: #a6e9cf; margin-bottom: 1.25rem; }
.story-copy h1 { margin: 0 0 1.25rem; font-size: clamp(2.8rem, 5vw, 5.1rem); font-weight: 650; line-height: .98; letter-spacing: -.055em; }
.story-copy > p:last-child { max-width: 520px; margin: 0; color: rgba(255,255,255,.7); font-size: 1.05rem; line-height: 1.7; }
.route-card { position: relative; z-index: 1; max-width: 530px; padding: 1.3rem 1.5rem; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; backdrop-filter: blur(12px); }
.route-line { display: flex; align-items: center; margin-bottom: .5rem; }
.route-line span:first-child, .route-line span:last-child { width: 12px; height: 12px; background: #a6e9cf; border: 3px solid rgba(166,233,207,.25); outline: 2px solid #a6e9cf; border-radius: 50%; }
.route-line span:nth-child(2) { flex: 1; height: 1px; margin: 0 8px; background: repeating-linear-gradient(90deg,#75baa7 0 6px,transparent 6px 11px); }
.route-meta, .route-kpis { display: flex; justify-content: space-between; gap: 1rem; color: rgba(255,255,255,.65); font-size: .78rem; }
.route-kpis { align-items: end; margin-top: 1rem; }
.route-kpis strong { color: white; font-size: 1.35rem; }
.story-foot { position: relative; z-index: 1; margin: 2rem 0 0; color: rgba(255,255,255,.4); font-size: .75rem; }
.login-panel { display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(100%, 430px); }
.login-card h2 { margin: .35rem 0 .65rem; font-size: 2rem; letter-spacing: -.025em; }
.login-card .form-control { min-height: 50px; border-color: #dbe4df; }
.password-toggle { pointer-events: auto !important; border: 0; background: transparent; cursor: pointer; }
.security-note { display: flex; gap: .6rem; margin: 1.4rem auto 0; color: #84908d; font-size: .75rem; line-height: 1.45; }
.security-note i { flex: 0 0 auto; color: var(--gocmr-green); font-size: 1.1rem; }

/* App shell */
.app-page { min-height: 100vh; overflow-x: hidden; }
.app-frame { min-height: 100vh; }
.app-sidebar { position: fixed; z-index: 1030; inset: 0 auto 0 0; display: flex; flex-direction: column; width: var(--gocmr-sidebar); padding: 1.35rem 1rem 1rem; color: #fff; background: var(--gocmr-deep); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 .5rem; }
.sidebar-head .brand img { height: 34px; }
.org-switcher { margin: 1.75rem 0 1rem; padding: .75rem; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.09); border-radius: 12px; }
.org-switcher label { display: block; margin-bottom: .25rem; color: rgba(255,255,255,.48); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.org-switcher .form-select { min-height: 30px; padding: .1rem 1.5rem .1rem 0; color: #fff; background-color: transparent; border: 0; box-shadow: none; font-size: .82rem; font-weight: 600; }
.org-switcher option { color: #142f2c; }
.sidebar-nav { display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; min-height: 42px; padding: .65rem .75rem; color: rgba(255,255,255,.68); border-radius: 9px; text-decoration: none; font-size: .86rem; transition: .18s ease; }
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav a.active { color: #fff; background: var(--gocmr-green-2); box-shadow: 0 6px 14px rgba(0,0,0,.14); }
.sidebar-nav a i { width: 28px; font-size: 1.15rem; }
.nav-badge { min-width: 22px; margin-left: auto; padding: 1px 6px; text-align: center; background: rgba(255,255,255,.12); border-radius: 99px; font-size: .68rem; }
.nav-label { margin: 1.1rem .75rem .35rem; color: rgba(255,255,255,.35); font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.api-health, .user-menu { display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; }
.api-health { color: rgba(255,255,255,.72); }
.api-health strong, .api-health small, .user-menu strong, .user-menu small { display: block; overflow: hidden; max-width: 145px; text-overflow: ellipsis; white-space: nowrap; }
.api-health strong, .user-menu strong { font-size: .76rem; }
.api-health small, .user-menu small { color: rgba(255,255,255,.4); font-size: .68rem; }
.status-dot { width: 8px; height: 8px; background: #56d89c; border-radius: 50%; box-shadow: 0 0 0 4px rgba(86,216,156,.12); }
.user-menu { width: 100%; margin-top: .25rem; color: rgba(255,255,255,.8); background: transparent; border: 0; border-radius: 9px; text-align: left; }
.user-menu:hover { background: rgba(255,255,255,.06); }
.user-menu .avatar { color: var(--gocmr-deep); background: #a6e9cf; }
.app-main { min-height: 100vh; margin-left: var(--gocmr-sidebar); }
.app-topbar { position: sticky; z-index: 1010; top: 0; display: flex; align-items: center; gap: 1rem; height: 66px; padding: 0 clamp(1rem,3vw,2rem); background: rgba(255,255,255,.91); border-bottom: 1px solid var(--gocmr-line); backdrop-filter: blur(12px); }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; color: #5b6b68; background: transparent; border: 0; border-radius: 9px; font-size: 1.15rem; }
.icon-button:hover { color: var(--gocmr-green); background: #edf3f0; }
.global-search { display: flex; align-items: center; width: min(470px, 45vw); gap: .5rem; }
.global-search input { width: 100%; color: var(--gocmr-ink); background: transparent; border: 0; outline: 0; }
.global-search i { color: #8a9895; font-size: 1.15rem; }
.global-search kbd { padding: .15rem .35rem; color: #82908d; background: #f0f3f1; border: 1px solid #e0e6e3; border-radius: 4px; font-size: .65rem; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.notification-button { position: relative; }
.notification-button span { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; background: #e57455; border: 1px solid white; border-radius: 50%; }
.page-content { max-width: 1520px; min-height: calc(100vh - 66px); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.loading-state { display: flex; align-items: center; justify-content: center; gap: .75rem; min-height: 60vh; color: #687875; }
.page-header-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header-row h1 { margin: 0; font-size: clamp(1.55rem,2.6vw,2.15rem); letter-spacing: -.035em; }
.page-header-row p { margin: .35rem 0 0; color: #71817e; }
.page-actions { display: flex; gap: .5rem; }

/* Components */
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; margin-bottom: 1rem; }
.metric-card { min-height: 144px; padding: 1.25rem; background: white; border: 1px solid var(--gocmr-line); border-radius: 14px; box-shadow: 0 2px 10px rgba(22,49,44,.025); }
.metric-card-head { display: flex; align-items: center; justify-content: space-between; color: #6c7d79; font-size: .78rem; }
.metric-icon { display: grid; place-items: center; width: 34px; height: 34px; color: var(--gocmr-green); background: var(--gocmr-mint); border-radius: 9px; font-size: 1.1rem; }
.metric-value { margin: 1rem 0 .15rem; color: var(--gocmr-ink); font-size: 2rem; font-weight: 700; letter-spacing: -.04em; }
.metric-trend { color: #7b8b88; font-size: .72rem; }
.metric-trend .up { color: #187b60; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(280px,.85fr); gap: 1rem; }
.panel { background: white; border: 1px solid var(--gocmr-line); border-radius: 14px; box-shadow: 0 2px 10px rgba(22,49,44,.025); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 66px; padding: 1rem 1.25rem; border-bottom: 1px solid #edf1ef; }
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel-head p { margin: .2rem 0 0; color: #82908d; font-size: .75rem; }
.panel-body { padding: 1.15rem; }
.table-responsive { min-height: 120px; }
.data-table { width: 100%; margin: 0; }
.data-table th { padding: .65rem 1rem; color: #82908d; background: #fbfcfb; border-bottom-color: #e8edeb; font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
.data-table td { padding: .9rem 1rem; vertical-align: middle; border-bottom-color: #edf1ef; font-size: .8rem; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #f7faf8; }
.ref { color: var(--gocmr-ink); font-weight: 650; }
.subtle { display: block; color: #8a9794; font-size: .7rem; }
.status-badge { display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .55rem; border-radius: 99px; font-size: .67rem; font-weight: 650; white-space: nowrap; }
.status-badge::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.status-draft, .status-pending, .status-pending_verification { color: #6c7775; background: #edf0ef; }
.status-ready, .status-prepared, .status-active, .status-available { color: #176b5b; background: #dff4eb; }
.status-in_transit, .status-issuing, .status-running, .status-retrying { color: #2569a8; background: #e4f0fb; }
.status-delivered, .status-issued, .status-succeeded { color: #566624; background: #eef4d8; }
.status-closed { color: #4b5452; background: #e8ebea; }
.status-cancelled, .status-failed, .status-invalid, .status-revoked { color: #b63c32; background: #fde8e6; }
.filter-bar { display: flex; align-items: center; gap: .65rem; padding: .85rem 1rem; background: white; border: 1px solid var(--gocmr-line); border-radius: 12px; margin-bottom: 1rem; }
.filter-bar .filter-search { position: relative; flex: 1; }
.filter-search i { position: absolute; z-index: 1; top: 50%; left: .75rem; color: #8b9896; transform: translateY(-50%); }
.filter-search input { padding-left: 2.3rem; }
.filter-bar select { width: auto; min-width: 150px; }
.empty-state { display: grid; place-items: center; min-height: 280px; padding: 2rem; text-align: center; }
.empty-state i { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 1rem; color: var(--gocmr-green); background: var(--gocmr-mint); border-radius: 18px; font-size: 1.7rem; }
.empty-state h3 { margin: 0 0 .35rem; font-size: 1rem; }
.empty-state p { max-width: 360px; color: #788783; font-size: .8rem; }
.activity-list { display: flex; flex-direction: column; }
.activity-item { position: relative; display: flex; gap: .8rem; padding: .8rem 0; }
.activity-item:not(:last-child)::after { content: ""; position: absolute; top: 40px; bottom: -5px; left: 15px; width: 1px; background: #e1e8e4; }
.activity-icon { z-index: 1; display: grid; place-items: center; flex: 0 0 auto; width: 31px; height: 31px; color: var(--gocmr-green); background: #edf6f2; border-radius: 50%; }
.activity-item p { margin: 0; font-size: .78rem; line-height: 1.4; }
.activity-item time { color: #92a09d; font-size: .68rem; }
.route-progress { display: flex; align-items: center; min-width: 150px; }
.route-progress span:not(.route-dot) { flex: 1; height: 2px; background: #dce5e1; }
.route-dot { width: 8px; height: 8px; background: #cdd7d3; border-radius: 50%; }
.route-dot.done { background: var(--gocmr-green-2); }
.card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; }
.entity-card { padding: 1.15rem; background: white; border: 1px solid var(--gocmr-line); border-radius: 13px; cursor: pointer; transition: .18s; }
.entity-card:hover { border-color: #abcac0; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(18,61,53,.06); }
.entity-card-head { display: flex; align-items: start; justify-content: space-between; gap: .7rem; }
.entity-card h3 { margin: 0; font-size: .92rem; }
.entity-card p { margin: .3rem 0 0; color: #7c8c89; font-size: .74rem; }
.entity-meta { display: flex; flex-wrap: wrap; gap: .4rem .8rem; margin-top: 1rem; padding-top: .8rem; color: #647571; border-top: 1px solid #edf1ef; font-size: .7rem; }
.entity-meta i { color: var(--gocmr-green); }
.secret-box { display: flex; align-items: center; gap: .5rem; padding: .75rem; background: #102c2a; border-radius: 9px; color: #d9eee6; }
.secret-box code { flex: 1; overflow: hidden; color: inherit; text-overflow: ellipsis; white-space: nowrap; }
.detail-drawer { width: min(560px,100vw) !important; }
.detail-drawer .offcanvas-header { padding: 1.5rem; border-bottom: 1px solid var(--gocmr-line); }
.detail-drawer .offcanvas-body { padding: 1.5rem; }
.detail-list { display: grid; grid-template-columns: 130px 1fr; gap: .75rem 1rem; font-size: .8rem; }
.detail-list dt { color: #82908d; font-weight: 500; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; font-weight: 550; }
.section-title { margin: 1.5rem 0 .8rem; font-size: .75rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.timeline { border-left: 1px solid #dce5e1; margin-left: 7px; padding-left: 1.2rem; }
.timeline-item { position: relative; padding: 0 0 1.2rem; }
.timeline-item::before { content: ""; position: absolute; top: 4px; left: -1.55rem; width: 10px; height: 10px; background: white; border: 2px solid var(--gocmr-green-2); border-radius: 50%; }
.timeline-item strong { display: block; font-size: .8rem; }
.timeline-item span { color: #82908d; font-size: .7rem; }
.modal-header { padding: 1.25rem 1.5rem; }
.modal-body { padding: 1.5rem; }
.form-section-title { margin: 0 0 1rem; padding-bottom: .6rem; border-bottom: 1px solid #e8edeb; font-size: .8rem; font-weight: 700; }
.repeater-row { padding: .9rem; background: #f7f9f8; border: 1px solid #e5ebe8; border-radius: 9px; }
.copy-button { color: inherit; background: transparent; border: 0; }
.toast { border: 1px solid #dce5e1; box-shadow: 0 14px 35px rgba(13,54,47,.15); }
.skeleton { overflow: hidden; min-height: 15px; background: #edf1ef; border-radius: 5px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 991.98px) {
  .login-shell { display: block; }
  .login-story { display: none; }
  .login-panel { min-height: 100vh; }
  .app-sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar-open .app-sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 1020; inset: 0; display: none; background: rgba(5,29,26,.48); }
  .sidebar-open .sidebar-scrim { display: block; }
  .app-main { margin-left: 0; }
}
@media (max-width: 680px) {
  .app-topbar { gap: .45rem; }
  .global-search { width: auto; flex: 1; }
  .global-search kbd { display: none; }
  .metric-grid, .card-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 120px; }
  .page-header-row { align-items: start; flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar select { width: 100%; }
  .data-table th:nth-child(3), .data-table td:nth-child(3) { display: none; }
  .login-panel { padding: 1.25rem; }
  .detail-list { grid-template-columns: 1fr; gap: .2rem; }
  .detail-list dd { margin-bottom: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; }
}
