/* Expedigit brand: deep navy #071A48, slate #283545, accent blue #0D78E1, gold #AB8D45 */
:root {
  --navy: #071a48;
  --navy-2: #0e2662;
  --slate: #283545;
  --blue: #0d78e1;
  --blue-soft: #e7f1fc;
  --gold: #ab8d45;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2333;
  --muted: #6b7686;
  --line: #e2e7ef;
  --green: #1f9d63;
  --amber: #d99a1c;
  --red: #d64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(7,26,72,.06), 0 4px 14px rgba(7,26,72,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.side { width: 232px; background: var(--navy); color: #c9d3e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { padding: 22px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { width: 160px; display: block; }
.brand-sub { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); margin-top: 8px; }
nav { padding: 10px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #7f8cab; padding: 14px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #d5ddee; text-decoration: none; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-item .count { margin-left: auto; background: rgba(255,255,255,.14); font-size: 11px; border-radius: 10px; padding: 1px 7px; }
.nav-item .count.alert { background: var(--red); color: #fff; }
.side-foot { font-size: 11px; color: #7f8cab; padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 16px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 20px; margin: 0; color: var(--navy); font-weight: 700; }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
#search { width: 260px; }
.menu { display: none; }
.view { padding: 24px 28px 60px; }

/* Controls */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
textarea { min-height: 80px; resize: vertical; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #0a66c2; }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }

/* Cards and grids */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 18px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 2fr 1fr; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.card h3 .right { margin-left: auto; font-weight: 500; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.accent { border-top: 3px solid var(--blue); }
.kpi.warn { border-top: 3px solid var(--amber); }
.kpi.bad { border-top: 3px solid var(--red); }
.kpi.good { border-top: 3px solid var(--green); }
.kpi.gold { border-top: 3px solid var(--gold); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.tabs { display: inline-flex; background: #e9edf4; border-radius: 9px; padding: 3px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; font: inherit; color: var(--slate); }
.tabs button.on { background: #fff; color: var(--navy); font-weight: 600; box-shadow: var(--shadow); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafd; }
td.num, th.num { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); padding: 26px; text-align: center; }

/* Badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: #edf0f5; color: var(--slate); white-space: nowrap; }
.b-green { background: #e3f5ec; color: var(--green); }
.b-amber { background: #fcf2de; color: #a66f00; }
.b-red { background: #fbe7e7; color: var(--red); }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-navy { background: var(--navy); color: #fff; }
.b-gold { background: #f5efe1; color: var(--gold); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* Lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li .main-t { font-weight: 600; }
.li .sub-t { color: var(--muted); font-size: 12.5px; }
.li .end { margin-left: auto; text-align: right; }

/* Kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kcol { background: #e9edf4; border-radius: var(--radius); width: 250px; flex-shrink: 0; padding: 10px; min-height: 120px; }
.kcol.over { outline: 2px dashed var(--blue); }
.kcol-h { display: flex; justify-content: space-between; font-weight: 700; color: var(--navy); font-size: 12.5px; padding: 2px 4px 10px; }
.kcol-h .sum { color: var(--muted); font-weight: 500; }
.kcard { background: #fff; border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; border-left: 3px solid var(--line); }
.kcard.hot { border-left-color: var(--red); }
.kcard.warm { border-left-color: var(--amber); }
.kcard.cold { border-left-color: #8ea4c6; }
.kcard .t { font-weight: 600; }
.kcard .m { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }

/* Bars */
.bar { height: 8px; background: #e9edf4; border-radius: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: 10px; }
.bar.gold > span { background: var(--gold); }
.funnel-row { display: grid; grid-template-columns: minmax(80px, 120px) minmax(40px, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.funnel-row .bar { height: 20px; }
.score-row { display: grid; grid-template-columns: 110px 1fr 30px; gap: 10px; align-items: center; margin-bottom: 8px; }

/* Detail page */
.detail-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; color: var(--navy); font-size: 22px; }
.detail-head .meta { color: var(--muted); margin-top: 4px; }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; }
.back { color: var(--blue); cursor: pointer; display: inline-block; margin-bottom: 12px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; }
.kv .k { color: var(--muted); }
.notes { white-space: pre-wrap; }
.confidential { background: #fff8e6; border: 1px solid #f1dfb0; color: #7a5a00; padding: 8px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 16px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(7,26,72,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px 20px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.form label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-actions .spacer { flex: 1; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-grid .btn { padding: 14px; }

.hidden { display: none !important; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 9px; z-index: 60; box-shadow: var(--shadow); }
.search-results { position: absolute; right: 28px; top: 62px; width: 420px; max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.12); z-index: 20; }
.search-results .li { padding: 10px 14px; }
.muted { color: var(--muted); }
.red { color: var(--red); }
.green { color: var(--green); }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.goal-big { font-size: 30px; font-weight: 800; color: var(--navy); }
.timeline .li { cursor: default; align-items: flex-start; }

@media (max-width: 1000px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .side { position: fixed; left: -240px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .menu { display: block; }
  .top { padding: 12px 16px; }
  .view { padding: 16px; }
  #search { width: 140px; }
  .form { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .search-results { left: 16px; right: 16px; width: auto; }
}

/* Parts a role can't see (the server also leaves the data out) */
body.no-money .money, body.no-inv .inv, body.no-exp .exp { display: none !important; }

/* Sign-in */
.auth { position: fixed; inset: 0; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, #13306f 100%); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 70; }
.auth-card { background: #fff; border-radius: 16px; width: 100%; max-width: 400px; padding: 30px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-card img { width: 190px; display: block; margin: 0 auto 6px; }
.auth-card .sub { text-align: center; color: var(--gold); letter-spacing: .18em; text-transform: uppercase; font-size: 11px; margin-bottom: 22px; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin: 12px 0 4px; }
.auth-card .btn { width: 100%; margin-top: 18px; padding: 11px; }
.auth-card .err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.auth-card p { color: var(--muted); font-size: 13px; }

/* ---------- Phone layout (Android and iPhone) ---------- */
.bottom-nav, .fab, .side-backdrop, .search-toggle { display: none; }
.phone-links { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 20px; background: var(--blue-soft); color: var(--blue); font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.chip.wa { background: #e3f5ec; color: #128c4a; }

@media (max-width: 760px) {
  body { font-size: 15px; -webkit-tap-highlight-color: transparent; }
  /* 16px stops phones zooming in when you tap a field */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }
  .btn { padding: 10px 16px; }
  .btn.small { padding: 8px 12px; font-size: 13.5px; }

  /* Top bar: title + search icon; "+ New" moves to the round button */
  .top { padding: 10px 12px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .top h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu { display: none; }
  #quickAdd { display: none; }
  .search-toggle { display: block; font-size: 22px; color: var(--navy); }
  #search { display: none; }
  body.search-on #search { display: block; position: absolute; left: 10px; right: 52px; top: 8px; width: auto; z-index: 6; }
  body.search-on .top h1 { visibility: hidden; }
  .search-results { position: fixed; top: 60px; left: 8px; right: 8px; width: auto; max-height: 70vh; }

  .view { padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); }

  /* Side menu slides in over a dimmed page */
  .side { position: fixed; left: -270px; width: 260px; z-index: 45; transition: left .2s; height: 100%; }
  .side.open { left: 0; }
  .side-backdrop { position: fixed; inset: 0; background: rgba(7,26,72,.45); z-index: 44; }
  .side-backdrop.on { display: block; }
  .nav-item { padding: 12px; }

  /* Bottom bar */
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(7,26,72,.06); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; }
  .bottom-nav a span { font-size: 19px; line-height: 1.2; }
  .bottom-nav a.on { color: var(--blue); }
  .fab { display: flex; align-items: center; justify-content: center; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 31;
    width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; font-size: 30px; line-height: 1;
    box-shadow: 0 6px 18px rgba(13,120,225,.4); cursor: pointer; }
  .fab.hidden, body.modal-on .fab, body.modal-on .bottom-nav { display: none; }

  /* Numbers: two per row */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; border-radius: 12px; }
  .kpi .value { font-size: 20px; }
  .kpi .label { font-size: 10.5px; }
  .grid { gap: 12px; }
  .mt { margin-top: 12px; }

  /* Lists and pages */
  .li { padding: 12px 2px; }
  .detail-head h2 { font-size: 19px; }
  .detail-head .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .kv { grid-template-columns: 110px 1fr; }
  .toolbar { gap: 8px; }
  .toolbar .muted { display: none; }
  .toolbar select { flex: 1; min-width: 0; }
  .tabs { overflow-x: auto; max-width: 100%; }
  .tabs button { white-space: nowrap; padding: 8px 12px; }
  .funnel-row { grid-template-columns: 95px 1fr auto; font-size: 12.5px; }

  /* Boards: one column at a time, swipe sideways */
  .kanban { scroll-snap-type: x mandatory; gap: 10px; margin: 0 -12px; padding: 0 12px 10px; }
  .kcol { width: 82vw; scroll-snap-align: start; }
  .kcard { padding: 12px; }

  /* Tables become cards: each row a card, each cell "label: value" */
  table.cardable, table.cardable tbody, table.cardable tr, table.cardable td { display: block; width: 100%; }
  table.cardable tr.head-row { display: none; }
  table.cardable tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  table.cardable td { border: 0; padding: 5px 0; display: block; text-align: right; overflow: hidden; }
  table.cardable td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding-top: 2px; }
  table.cardable td .bar { margin-left: auto; max-width: 60%; }
  table.cardable td:not([data-label])::before, table.cardable td[data-label=""]::before { content: none; }
  table.cardable td:first-child { font-size: 16px; text-align: left; }
  table.cardable td:first-child::before { content: none; }
  table.cardable td:empty { display: none; }
  table.cardable td.num { text-align: right; }
  table.cardable .empty { text-align: center; }
  .card.table-wrap { background: transparent; border: 0; box-shadow: none; padding: 0; }
  tr.click:hover td { background: transparent; }

  /* Forms open full screen, Save always visible at the bottom */
  .modal { padding: 0; align-items: stretch; }
  .modal-card { max-width: none; border-radius: 0; min-height: 100%; display: flex; flex-direction: column; }
  .modal-head { position: sticky; top: 0; background: #fff; z-index: 2; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
  .modal-body { flex: 1; padding: 16px 16px 0; }
  .form-actions { position: sticky; bottom: 0; background: #fff; margin: 18px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .form-actions .btn { flex: 1; }
  .form-actions .spacer { display: none; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .quick-grid .btn { padding: 16px 10px; }

  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); text-align: center; }
  .auth-card { padding: 24px 20px; }
}

/* Android app: pull-to-refresh hint */
.pull-hint { position: fixed; top: 64px; left: 50%; transform: translate(-50%, -20px); background: var(--navy); color: #fff; font-size: 13px;
  padding: 6px 14px; border-radius: 20px; opacity: 0; transition: opacity .15s, transform .15s; z-index: 60; pointer-events: none; }
.pull-hint.on { opacity: 1; transform: translate(-50%, 0); }

/* SLA review screen */
.sla-h { margin: 22px 0 10px; font-size: 15px; color: var(--navy); border-top: 1px solid var(--line); padding-top: 16px; }
.sla-row { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 12px 40px 12px 12px; margin-bottom: 10px; background: #fafbfd; }
.sla-x { position: absolute; top: 6px; right: 6px; }
.sla-pay { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.sla-phase summary::-webkit-details-marker { display: none; }
.sla-phase { display: block; cursor: default; }
.sla-phase.now { background: #f5f9ff; border-radius: 8px; padding-left: 6px; padding-right: 6px; }
@media (max-width: 760px) { .sla-pay { grid-template-columns: 1fr 1fr; } .sla-pay input:first-child { grid-column: 1 / -1; } }

/* Install button (Edge/Chrome on Windows and Mac) */
.side-foot .install-app { width: 100%; margin-top: 10px; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); font-size: 12.5px; }
#authForm .install-app { width: 100%; margin-top: 10px; }
