
:root {
  --navy: #071b35;
  --navy-2: #0b2548;
  --blue: #0b6cfb;
  --blue-dark: #0758cf;
  --blue-soft: #eaf3ff;
  --ink: #0f1f34;
  --muted: #66758a;
  --muted-2: #8b98aa;
  --line: #e3e9f0;
  --canvas: #f6f8fb;
  --surface: #ffffff;
  --success: #2ca24c;
  --success-soft: #eaf8ee;
  --warning: #ef9a2d;
  --warning-soft: #fff5e7;
  --danger: #df3d3d;
  --danger-soft: #fff0f0;
  --shadow: 0 8px 24px rgba(17, 38, 68, .07);
  --shadow-lg: 0 20px 50px rgba(10, 31, 59, .18);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(11, 108, 251, .2); outline-offset: 2px; }
input, select { color: var(--ink); }
h1, h2, h3, h4, p { margin-top: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 10px 18px; display: flex; flex-direction: column; background: linear-gradient(180deg, var(--navy) 0%, #06182e 100%); color: white; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 14px 30px; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.72); border-radius: 8px; font-size: 14px; font-weight: 700; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.nav { display: grid; gap: 6px; }
.nav-link { width: 100%; min-height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 7px; background: transparent; color: #d5dfec; font-weight: 600; text-align: left; }
.nav-link:hover { background: rgba(255,255,255,.07); color: white; }
.nav-link.active { background: var(--blue); color: white; box-shadow: 0 6px 18px rgba(11,108,251,.28); }
.nav-icon { width: 19px; text-align: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; padding: 16px 10px 4px; display: flex; align-items: center; gap: 10px; border-top: 1px solid rgba(255,255,255,.1); }
.user-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: white; color: var(--navy); font-size: 11px; font-weight: 700; }
.sidebar-footer strong, .sidebar-footer span { display: block; }
.sidebar-footer strong { font-size: 12px; }
.sidebar-footer span { margin-top: 2px; color: #9fb0c6; font-size: 10px; }

.workspace { min-width: 0; padding: 0 28px 44px; }
.topbar { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 0; font-size: 19px; line-height: 1.2; }
.breadcrumb { margin: 0; color: var(--muted); font-size: 11px; font-weight: 600; }
.save-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.save-state > span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.view { display: none; padding-top: 22px; }
.view.active { display: block; }
.hidden { display: none !important; }

.scenario-card, .table-card, .kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 7px rgba(17,38,68,.025); }
.scenario-card { padding: 16px 18px; }
.scenario-fields { display: grid; grid-template-columns: 1.25fr 1fr .92fr .92fr auto; gap: 14px; align-items: end; }
label { position: relative; display: block; color: #526177; font-size: 10px; font-weight: 600; }
label input, label select { width: 100%; height: 38px; margin-top: 7px; padding: 0 10px; border: 1px solid #d8e0ea; border-radius: 5px; background: white; color: var(--ink); font-size: 12px; font-weight: 500; outline: none; }
label input:focus, label select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,108,251,.08); }
label > span { position: absolute; right: 10px; bottom: 12px; color: var(--muted-2); font-size: 10px; font-weight: 500; pointer-events: none; }
label:has(> span) input { padding-right: 55px; }
.primary-button, .secondary-button, .row-button, .close-button, .icon-button { border-radius: 5px; font-weight: 600; }
.primary-button { min-height: 38px; padding: 0 16px; border: 1px solid var(--blue); background: var(--blue); color: white; font-size: 11px; }
.primary-button:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.secondary-button { min-height: 35px; padding: 0 13px; border: 1px solid #d7e0ea; background: white; color: var(--ink); font-size: 11px; }
.secondary-button:hover { border-color: #bdc9d7; background: #f9fbfd; }
.scenario-submit { min-width: 158px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.simulation-note { margin: 11px 1px 0; color: var(--muted); font-size: 11px; }
.simulation-note:empty { display: none; }

.kpi-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-card { min-height: 116px; padding: 16px; display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: start; }
.kpi-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-size: 18px; font-weight: 700; }
.kpi-card:nth-child(2) .kpi-icon { background: var(--success-soft); color: var(--success); }
.kpi-card:nth-child(3) .kpi-icon { background: #f0ebff; color: #7557d9; }
.kpi-card:nth-child(4) .kpi-icon { background: var(--warning-soft); color: var(--warning); }
.kpi-label { margin: 1px 0 8px; color: #526177; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { margin: 0; color: var(--ink); font-size: 21px; font-weight: 700; line-height: 1; }
.kpi-value small { margin-left: 3px; color: var(--muted); font-size: 10px; font-weight: 600; }
.kpi-sub { margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.comparison-card { margin-top: 14px; }
.card-heading { padding: 16px 18px 13px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.card-heading h2 { margin: 0; font-size: 14px; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; color: #607087; background: #fafbfd; font-size: 9px; font-weight: 700; text-align: left; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--line); font-size: 11px; vertical-align: middle; }
.comparison-table td:first-child { min-width: 150px; }
.barge-name { display: block; color: var(--ink); font-weight: 700; }
.barge-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.status-pill.warning .status-dot { background: var(--warning); }
.status-pill.danger .status-dot { background: var(--danger); }
.value-strong { font-weight: 700; }
.progress { width: 94px; height: 4px; margin-top: 5px; overflow: hidden; border-radius: 999px; background: #e8edf3; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.row-button { width: 30px; height: 30px; border: 1px solid #d9e2ec; background: white; color: var(--ink); }
.row-button:hover { border-color: var(--blue); color: var(--blue); }

.page-heading { margin-bottom: 15px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.page-heading h2 { margin: 3px 0 5px; font-size: 22px; }
.page-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 11px; }
.list-toolbar { min-height: 62px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.search-box { width: min(320px, 100%); height: 36px; padding: 0 11px; display: flex; align-items: center; gap: 8px; border: 1px solid #dce4ed; border-radius: 5px; color: var(--muted); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.count-label { color: var(--muted); font-size: 10px; }
.data-row { padding: 14px 16px; display: grid; grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(90px, .65fr)) auto; gap: 14px; align-items: center; border-top: 1px solid var(--line); }
.data-row:first-child { border-top: 0; }
.data-row-title { min-width: 0; }
.data-row-title h4 { margin: 0; font-size: 12px; }
.data-row-title p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.data-cell-label { display: block; margin-bottom: 3px; color: var(--muted-2); font-size: 8px; text-transform: uppercase; }
.data-cell-value { color: var(--ink); font-size: 10px; font-weight: 600; }
.data-actions { display: flex; gap: 7px; justify-content: flex-end; }
.action-button { min-height: 31px; padding: 0 11px; border: 1px solid #d7e0ea; border-radius: 5px; background: white; color: var(--ink); font-size: 10px; font-weight: 600; }
.action-button:hover { border-color: var(--blue); color: var(--blue); }
.action-button.danger:hover { border-color: #efb1b1; color: var(--danger); }
.empty-state { padding: 46px 18px; color: var(--muted); font-size: 11px; text-align: center; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(7,27,53,.3); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; z-index: 40; width: min(620px, 96vw); height: 100vh; display: flex; flex-direction: column; background: white; box-shadow: var(--shadow-lg); transform: translateX(102%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.detail-drawer { width: min(420px, 96vw); }
.drawer-header { min-height: 84px; padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 4px 0 0; font-size: 17px; }
.close-button { width: 33px; height: 33px; border: 0; background: transparent; color: var(--muted); font-size: 22px; }
.close-button:hover { background: #f1f4f8; color: var(--ink); }
.drawer-form { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.form-tabs { padding: 0 22px; display: flex; gap: 22px; border-bottom: 1px solid var(--line); }
.form-tab { min-height: 46px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 10px; font-weight: 600; }
.form-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.form-panel { display: none; min-height: 0; flex: 1; padding: 8px 22px 24px; overflow-y: auto; }
.form-panel.active { display: block; }
.destination-panel { display: block; }
.section-heading { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.section-heading:first-child { margin-top: 0; padding-top: 16px; border-top: 0; }
.section-heading.inline { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.section-heading h3 { margin: 0; font-size: 12px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.form-grid { margin-top: 14px; display: grid; gap: 12px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.drawer-actions { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); background: white; }
.dynamic-rows { margin-top: 14px; display: grid; gap: 10px; }
.dynamic-row { padding: 12px; display: grid; gap: 9px; align-items: end; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfe; }
.cargo-row { grid-template-columns: 1fr .8fr 1fr 34px; }
.propulsion-row { grid-template-columns: 1fr 65px 100px 1fr 1fr 34px; }
.cost-row { grid-template-columns: 1.15fr 1fr .8fr 75px 34px; }
.dynamic-row label { font-size: 9px; }
.dynamic-row label input, .dynamic-row label select { height: 34px; margin-top: 5px; font-size: 10px; }
.icon-button { width: 34px; height: 34px; border: 1px solid #d7e0ea; background: white; color: var(--muted); }
.icon-button:hover { border-color: #efb1b1; color: var(--danger); }
.handling-list { margin-top: 12px; display: grid; gap: 8px; }
.handling-row { padding: 10px; display: grid; grid-template-columns: minmax(115px, 1fr) repeat(3, minmax(85px, .8fr)); gap: 8px; align-items: end; border: 1px solid var(--line); border-radius: 5px; }
.handling-row > strong { padding-bottom: 11px; font-size: 10px; }
.handling-row label { font-size: 8px; }
.handling-row input { height: 32px; font-size: 10px; }

.detail-content { min-height: 0; flex: 1; padding: 20px 22px; overflow-y: auto; }
.detail-summary { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; }
.detail-line { min-height: 38px; padding: 9px 11px; display: flex; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); font-size: 10px; }
.detail-line:first-child { border-top: 0; }
.detail-line span { color: var(--muted); }
.detail-line strong { text-align: right; }
.detail-section { margin-top: 18px; }
.detail-section h3 { font-size: 11px; }
.detail-note { padding: 13px; border-radius: 7px; background: var(--success-soft); color: #216a35; font-size: 10px; line-height: 1.55; }
.detail-note.warning { background: var(--warning-soft); color: #8b5c1d; }
.propulsion-select { width: 100%; height: 36px; border: 1px solid #d8e0ea; border-radius: 5px; background: white; padding: 0 9px; font-size: 10px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: 340px; padding: 11px 14px; border-radius: 6px; background: var(--navy); color: white; box-shadow: var(--shadow-lg); font-size: 11px; opacity: 0; transform: translateY(14px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 1080px) {
  .scenario-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-submit { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .data-row { grid-template-columns: minmax(190px, 1fr) repeat(2, minmax(90px,.6fr)) auto; }
  .data-row > :nth-child(4) { display: none; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 20; width: 100%; height: auto; padding: 9px 12px; flex-direction: row; align-items: center; }
  .brand { padding: 0 10px 0 0; }
  .brand-mark { display: none; }
  .brand strong { font-size: 13px; }
  .nav { margin-left: auto; display: flex; gap: 4px; }
  .nav-link { width: auto; min-height: 36px; padding: 0 10px; font-size: 10px; }
  .nav-icon { display: none; }
  .sidebar-footer { display: none; }
  .workspace { padding: 0 14px 28px; }
  .topbar { min-height: 68px; }
  .scenario-fields { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { min-height: 104px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .data-row { grid-template-columns: 1fr auto; }
  .data-row > :nth-child(2), .data-row > :nth-child(3), .data-row > :nth-child(4) { display: none; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .cargo-row, .propulsion-row, .cost-row { grid-template-columns: 1fr 1fr; }
  .dynamic-row .icon-button { justify-self: end; grid-column: 2; }
  .handling-row { grid-template-columns: 1fr 1fr; }
  .handling-row > strong { grid-column: span 2; padding-bottom: 0; }
  .form-tabs { gap: 14px; overflow-x: auto; }
}
