/* Maritime Panel. Tokens: .design/DESIGN.md */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-greek-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --navy: #1E2E5E; --navy-deep: #141F42; --navy-soft: #2B3F7A;
  --sand: #D8B479; --bg: #FFFFFF; --surface: #F2F4F8; --border: #DCE1EB; --muted: #56607A;
  --danger: #9B1C1C; --danger-bg: #FDECEC;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 10px; --r-lg: 18px;
  --shadow: 0 1px 2px rgba(20, 31, 66, 0.06), 0 12px 32px -8px rgba(20, 31, 66, 0.18);
  --t-fast: 180ms; --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.6; color: var(--navy-deep); background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
h1 { margin: 0 0 var(--s4); font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; }
a { color: inherit; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; box-shadow: 0 0 0 2px var(--navy); }
.topbar :focus-visible { box-shadow: 0 0 0 2px #fff; }
.skip { position: absolute; left: var(--s4); top: -100px; background: var(--bg); padding: var(--s2) var(--s4); border-radius: var(--r-sm); z-index: 100; }
.skip:focus { top: var(--s2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s4);
  border: 2px solid transparent; border-radius: var(--r-sm); font: inherit; font-weight: 700; font-size: 15px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-soft); }
.btn-sand { background: var(--sand); color: var(--navy-deep); }
.btn-sand:hover { background: #E3C48F; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.btn-ghost:hover { border-color: #fff; background: rgba(255, 255, 255, 0.08); }
.btn-block { width: 100%; }

.topbar { background: var(--navy); color: #fff; }
.topbar-in { display: flex; align-items: center; gap: var(--s4); max-width: 1160px; margin: 0 auto; padding: var(--s2) var(--s4); min-height: 64px; }
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; font-weight: 800; letter-spacing: -0.01em; }
.menu { display: flex; gap: var(--s1); margin-left: var(--s4); flex: 1; }
.menu a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-sm); text-decoration: none; color: rgba(255, 255, 255, 0.82); font-weight: 600; }
.menu a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.menu a[aria-current="page"] { color: #fff; box-shadow: inset 0 -3px 0 var(--sand); border-radius: 0; }
.logout { margin: 0; }

.page { max-width: 1160px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); }
.flash { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); background: var(--bg); border-left: 4px solid var(--sand); border-radius: var(--r-sm); }

.tabbar { display: none; }

.bare-main { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); background: var(--navy); }
.login-card, .bare-card { width: 100%; max-width: 400px; background: var(--bg); color: var(--navy-deep); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s6) var(--s5); }
.bare-card h1 { margin: 0 0 var(--s3); }
.bare-card p { margin: 0 0 var(--s4); }
.bare-card .error-actions, .error-card .error-actions { margin: var(--s5) 0 0; }
.login-card .flash { margin: var(--s4) 0 0; background: var(--sand-tint); }
.login-card h1 { margin-top: var(--s4); }
.login-mark { margin: 0 auto; }
.login-card label { display: block; margin: var(--s4) 0 var(--s1); font-weight: 600; font-size: 14px; }
.login-card input[type="email"], .login-card input[type="password"] {
  width: 100%; min-height: 48px; padding: 0 var(--s3); font: inherit; color: var(--navy-deep);
  background: var(--bg); border: 1.5px solid var(--muted); border-radius: var(--r-sm);
}
.login-card :focus-visible { box-shadow: 0 0 0 2px var(--navy); }
.login-card input:focus-visible { outline-offset: 1px; border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy); }
.login-card .btn { margin-top: var(--s5); }
.alert { margin: 0 0 var(--s2); padding: var(--s3) var(--s4); color: var(--danger); background: var(--danger-bg); border-radius: var(--r-sm); font-weight: 600; }

/* Shared utilities */
[hidden] { display: none !important; }
.sr-only, .sr-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:root { --sand-tint: #F7EEDD; --navy-tint: #E9EDF6; }
h2 { margin: 0 0 var(--s3); font-size: 18px; line-height: 1.3; font-weight: 800; letter-spacing: -0.01em; }
.card > h2::after, .block > h2::after { content: ""; display: block; width: 32px; height: 3px; margin-top: var(--s2); background: var(--sand); border-radius: 2px; }
.btn-light { background: var(--bg); color: var(--navy); border-color: var(--border); }
.btn-light:hover { border-color: var(--navy); }
.tel { font-weight: 700; color: var(--navy); }
.empty { margin: 0; padding: var(--s4); color: var(--muted); background: var(--bg); border: 1.5px dashed var(--border); border-radius: var(--r-sm); }
.card .empty { border: 0; padding: 0; }

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
.page-head h1 { margin: 0; }
.page-head > p { margin: 0; }
.eyebrow { margin: 0 0 var(--s1); font-size: 14px; font-weight: 600; color: var(--muted); }
.eyebrow a { color: var(--navy); }
.head-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.summary { display: flex; flex-wrap: wrap; gap: var(--s2); margin: calc(-1 * var(--s3)) 0 var(--s4); }

/* Cards and columns */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5) var(--s4); margin: 0 0 var(--s4); min-width: 0; }
.cols { display: grid; gap: 0 var(--s4); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } .card { padding: var(--s5); } }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s6); }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); } }
.stat { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s4); background: var(--bg); border: 1px solid var(--border); border-top: 4px solid var(--navy); border-radius: var(--r-lg); text-decoration: none; transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
a.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-num { font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat-expiring { border-top-color: var(--sand); }
.stat-overdue { border-top-color: var(--danger); }
.stat-overdue .stat-num { color: var(--danger); }
.stat-owed { background: var(--navy); border-color: var(--navy); border-top-color: var(--sand); }
.stat-owed .stat-num { color: #fff; font-size: 24px; }
.stat-owed .stat-label { color: rgba(255, 255, 255, 0.78); }
.block { margin-bottom: var(--s6); }
.block > h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.block > h2::after { flex-basis: 100%; max-width: 32px; margin-top: 0; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 24px; padding: 0 var(--s2); font-size: 13px; border-radius: 12px; background: var(--navy-tint); color: var(--navy); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--sand); border-radius: var(--r-sm); }
.row-overdue { border-left-color: var(--danger); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; }
.row-title { font-size: 17px; font-weight: 800; color: var(--navy); text-decoration: none; }
.row-title:hover { text-decoration: underline; }
.row-sub { font-size: 15px; overflow-wrap: anywhere; }
.row-meta { font-size: 14px; }
.row-side { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.btn-call { background: var(--navy); color: #fff; min-width: 96px; }
.btn-call:hover { background: var(--navy-soft); }

/* Status and balance */
.badge, .bal { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--s3); border-radius: 14px; font-size: 13px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge-active { background: var(--navy); color: #fff; }
.badge-expiring { background: var(--sand-tint); color: var(--navy-deep); box-shadow: inset 0 0 0 1px var(--sand); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); box-shadow: inset 0 0 0 1px #F2B8B8; }
.badge-completed { background: var(--surface); color: var(--muted); }
.bal-owe { background: var(--danger-bg); color: var(--danger); }
.bal-credit { background: var(--navy-tint); color: var(--navy); }
.bal-paid { background: var(--surface); color: var(--muted); }

/* Facts list */
.facts { margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { font-size: 14px; color: var(--muted); font-weight: 600; flex: none; }
.facts dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.facts > .wide { display: block; }
.facts > .wide dd { text-align: left; font-weight: 400; margin-top: var(--s1); }
.pre { white-space: pre-line; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }

/* Checkout confirm (no JS dialog) */
.confirm { margin-top: var(--s4); }
.confirm summary { list-style: none; width: 100%; }
.confirm summary::-webkit-details-marker { display: none; }
.confirm[open] summary { border-color: var(--navy); }
.confirm-body { margin-top: var(--s3); padding: var(--s4); background: var(--sand-tint); border-radius: var(--r-sm); }
.confirm-body p { margin: 0 0 var(--s3); }
.confirm-body .btn { width: 100%; }
.confirm-row { margin-top: 0; }
.confirm-row .confirm-body { min-width: 240px; text-align: left; white-space: normal; }
.table .row-action { text-align: right; width: 1%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #7F1717; }
.head-actions { align-items: center; }

/* Forms */
.form fieldset.card { display: block; }
.form legend { float: left; width: 100%; padding: 0; margin: 0 0 var(--s4); font-size: 18px; font-weight: 800; }
.form legend + * { clear: both; }
.field { margin-bottom: var(--s4); }
.field:last-child { margin-bottom: 0; }
.form label, .filters label { display: block; margin-bottom: var(--s1); font-weight: 600; font-size: 14px; }
.form input:not([type="radio"]):not([type="hidden"]), .form select, .form textarea,
.filters input:not([type="radio"]):not([type="hidden"]), .filters select {
  display: block; width: 100%; min-height: 48px; padding: var(--s2) var(--s3); font: inherit; font-size: 16px; color: var(--navy-deep);
  background: var(--bg); border: 1.5px solid var(--muted); border-radius: var(--r-sm);
}
.form textarea { min-height: 96px; resize: vertical; }
.filters input:focus-visible, .filters select:focus-visible, .form input:focus-visible, .form select:focus-visible, .form textarea:focus-visible { outline-offset: 1px; border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy); }
.form [aria-invalid="true"] { border-color: var(--danger) !important; background: #FFFBFB; }
.field-error { margin: var(--s1) 0 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.req { color: var(--danger); }
.hint { margin: var(--s1) 0 0; font-size: 13px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); margin-bottom: var(--s4); }
.grid-2 > .field { margin-bottom: 0; }
.grid-2:last-child { margin-bottom: 0; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.money-input { position: relative; }
.money-input input { padding-right: 40px !important; font-variant-numeric: tabular-nums; }
.money-input span { position: absolute; right: var(--s3); top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s2); }
.form-actions .btn-navy { flex: 1 1 220px; min-height: 52px; font-size: 16px; }

/* Customer picker */
.picked { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); background: var(--navy-tint); border-radius: var(--r-sm); }
.picked-text { display: flex; flex-direction: column; min-width: 0; }
.picked-text strong { font-size: 17px; overflow-wrap: anywhere; }
.search { margin-bottom: var(--s4); }
.results { list-style: none; margin: var(--s2) 0 0; padding: 0; border-radius: var(--r-sm); overflow: hidden; }
.results:not(:empty) { border: 1px solid var(--border); }
.results li + li { border-top: 1px solid var(--border); }
.results button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 56px; padding: var(--s2) var(--s3); font: inherit; text-align: left; color: var(--navy-deep); background: var(--bg); border: 0; cursor: pointer; }
.results button:hover { background: var(--surface); }
.results .r-name { font-weight: 700; }
.results .r-meta { font-size: 13px; color: var(--muted); }
.results .r-none { padding: var(--s3); color: var(--muted); font-size: 14px; }
.divider { display: flex; align-items: center; gap: var(--s3); margin: var(--s4) 0 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.choices { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.form .choice { display: flex; align-items: center; gap: var(--s3); min-height: 52px; margin: 0; padding: var(--s2) var(--s3); font-size: 16px; font-weight: 600; border: 1.5px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--navy); flex: none; }
.choice:has(input:checked) { border-color: var(--navy); background: var(--navy-tint); }
.item-set:has(input[name="item_id"]:checked:not([value="new"])) .new-item { display: none; }
.item-set:has(input[name="item_id"]:checked:not([value="new"])) .choices { margin-bottom: 0; }

/* Tables (stack into rows on phones) */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); padding: var(--s2) var(--s3); border-bottom: 1.5px solid var(--border); }
.table td { padding: var(--s3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th, .table tfoot td { border-top: 1.5px solid var(--border); border-bottom: 0; color: var(--navy-deep); font-size: 15px; font-weight: 800; padding: var(--s3); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a { color: var(--navy); font-weight: 700; }

@media (max-width: 640px) {
  .menu { display: none; }
  .topbar-in { gap: var(--s2); }
  .topbar-in .btn { padding: 0 var(--s3); font-size: 14px; }
  .brand { min-width: 0; gap: var(--s2); }
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .brand img { flex: none; }
  .topbar-in .btn { white-space: nowrap; flex: none; }
  .topbar-in .btn-sand { margin-left: auto; }
  body.app { padding-bottom: 72px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--bg); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: flex; align-items: center; justify-content: center; min-height: 56px; text-decoration: none; font-size: 13px; font-weight: 700; color: var(--muted); }
  .tabbar a[aria-current="page"] { color: var(--navy); box-shadow: inset 0 3px 0 var(--sand); }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tfoot, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td, .table tbody tr:last-child td { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; }
  .table td:empty { display: none !important; }
  .table tfoot tr { display: flex; justify-content: space-between; border-top: 1.5px solid var(--border); padding-top: var(--s3); }
  .table tfoot th, .table tfoot td { display: block; width: auto; padding: 0; border: 0; }
  .table tfoot td::before { content: none; }
  .row-side { width: 100%; justify-content: space-between; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .table .row-action { width: 100%; justify-content: flex-end; padding-top: var(--s2); }
  .table .row-action::before { content: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* Filters and list summaries (Task 7) */
.filters { margin-bottom: var(--s4); }
.filter-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); align-items: end; }
.filter-grid .field { margin-bottom: 0; }
.filter-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.filter-actions .btn { flex: 1 1 140px; }
@media (min-width: 760px) {
  .filter-grid { grid-template-columns: 200px 200px minmax(0, 1fr) auto; }
  .filter-grid-one { grid-template-columns: minmax(0, 1fr) auto; }
  .filter-grid-dates { grid-template-columns: 200px 200px auto; }
  .filter-actions .btn { flex: none; }
}
.filters input[type="search"] { -webkit-appearance: none; appearance: none; }
.summary-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); margin: 0 0 var(--s3); font-size: 15px; }
.summary-line strong { font-size: 18px; color: var(--navy-deep); font-variant-numeric: tabular-nums; }
