:root {
  --navy: #17324d;
  --teal: #0f766e;
  --warm: #d99a2b;
  --paper: #f5f7f8;
  --card: #ffffff;
  --line: #d8e1e7;
  --muted: #667784;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(23, 50, 77, .13);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100%; color: var(--navy); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 4px; color: var(--teal); font-size: 11px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 50; transform: translateY(18px); opacity: 0; pointer-events: none; padding: 12px 14px; border-radius: 14px; color: white; background: var(--navy); box-shadow: var(--shadow); transition: opacity .18s ease, transform .18s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 390px); padding: 28px 22px; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); }
.brand-mark { display: grid; grid-template-columns: repeat(3, 12px); gap: 5px; margin-bottom: 22px; }
.brand-mark span { display: block; height: 34px; border-radius: 999px; background: var(--teal); }
.brand-mark span:nth-child(2) { height: 24px; margin-top: 10px; background: var(--warm); }
.brand-mark span:nth-child(3) { height: 16px; margin-top: 18px; background: var(--navy); }
.login-card h1 { margin: 0 0 10px; font-size: 34px; line-height: 1.04; letter-spacing: -.04em; }
.login-copy { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; width: 100%; border: 0; border-radius: 14px; padding: 12px 14px; text-decoration: none; font-weight: 800; }
.button-primary { color: white; background: var(--teal); }
.button-secondary { color: var(--navy); background: #eaf0f3; }
.secondary-link { display: block; margin-top: 18px; color: var(--teal); font-weight: 800; text-align: center; text-decoration: none; }
.dev-login { margin-top: 18px; }
.dev-login p { margin: 0 0 10px; color: var(--muted); font-size: 13px; font-weight: 750; }
.dev-users { display: grid; gap: 8px; }
.dev-users button { border: 1px solid var(--line); border-radius: 14px; padding: 12px; color: var(--navy); background: white; text-align: left; }
.form-error { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; color: #7f1d1d; background: #fff0f0; }

.mobile-shell { min-height: 100dvh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: calc(14px + env(safe-area-inset-top)) 16px 12px; background: rgba(245, 247, 248, .92); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(216, 225, 231, .7); }
.app-header h1 { margin: 0; font-size: 24px; line-height: 1.12; letter-spacing: -.035em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-link,.icon-button { min-height: 38px; border: 1px solid var(--line); border-radius: 999px; padding: 9px 12px; color: var(--navy); background: white; font-size: 12px; font-weight: 850; text-decoration: none; }

.view-stack { padding: 14px 14px 0; }
.view { display: grid; gap: 14px; }
.loading,.empty { padding: 24px 16px; border: 1px dashed #b9c7cf; border-radius: 18px; color: var(--muted); background: rgba(255, 255, 255, .65); text-align: center; }
.panel { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: 0 6px 22px rgba(23, 50, 77, .06); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.panel-head small,.muted { color: var(--muted); }

.card-list { display: grid; gap: 10px; }

.skeleton { display: grid; gap: 12px; }
.skeleton-card { display: grid; gap: 9px; padding: 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); }
.sk-line { height: 12px; border-radius: 999px; background: linear-gradient(100deg, #eef2f4 30%, #e2e9ed 50%, #eef2f4 70%); background-size: 220% 100%; animation: sk-shimmer 1.25s ease-in-out infinite; }
.sk-sm { width: 40%; } .sk-md { width: 60%; } .sk-lg { width: 85%; height: 15px; }
@keyframes sk-shimmer { from { background-position: 180% 0; } to { background-position: -40% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-line { animation: none; } }
.mobile-card { width: 100%; border: 1px solid var(--line); border-radius: 18px; padding: 13px; color: inherit; background: #fbfcfd; text-align: left; box-shadow: 0 4px 14px rgba(23, 50, 77, .04); }
.mobile-card:active { transform: translateY(1px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-title { margin: 0; font-size: 15px; line-height: 1.25; letter-spacing: -.015em; }
.card-code { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.card-meta { display: grid; gap: 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.badge { display: inline-flex; align-items: center; white-space: nowrap; border-radius: 999px; padding: 5px 8px; color: var(--navy); background: #edf2f5; font-size: 11px; font-weight: 850; }
.badge.inquiry { color: #715500; background: #fff2bf; }
.badge.offer { color: #7a3f00; background: #ffe4c1; }
.badge.approved,.badge.completed { color: #0f5132; background: #dff5ea; }
.badge.in_progress,.badge.planning,.badge.agreed { color: #17406f; background: #dfeeff; }
.badge.invoiced { color: #334155; background: #e8edf2; }
.more-note { margin: 2px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.filters { position: sticky; top: calc(66px + env(safe-area-inset-top)); z-index: 10; display: grid; gap: 8px; padding: 8px 0 2px; background: rgba(245, 247, 248, .92); backdrop-filter: blur(12px); }
.filters input,.filters select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; color: var(--navy); background: white; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.detail-dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; padding: 0; color: var(--navy); background: var(--paper); }
.detail-dialog::backdrop { background: rgba(23, 50, 77, .28); }
.detail-shell { min-height: 100%; display: grid; grid-template-rows: auto 1fr; }
.detail-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 16px 12px; background: rgba(245, 247, 248, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.detail-head h2 { margin: 0; font-size: 22px; line-height: 1.14; letter-spacing: -.035em; }
.detail-head .icon-button { min-height: 44px; padding: 11px 16px; border-radius: 12px; }
.detail-body { display: grid; align-content: start; gap: 14px; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
.detail-section { padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.detail-section h3 { margin: 0 0 10px; font-size: 15px; }
.detail-list { display: grid; grid-template-columns: 108px 1fr; gap: 9px 12px; margin: 0; }
.detail-list dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.detail-list dd { margin: 0; font-size: 14px; line-height: 1.45; }
.detail-empty { margin: 0; color: var(--muted); font-size: 13px; }
.detail-action { width: 100%; }
.description { white-space: pre-wrap; }
.fin-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--line); }
.fin-strip div { padding: 12px 10px; background: var(--card); text-align: center; }
.fin-strip small { display: block; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.fin-strip strong { display: block; margin-top: 5px; color: var(--navy); font-size: 15px; font-variant-numeric: tabular-nums; }
.fin-strip .pos strong { color: var(--teal); }
.fin-strip .neg strong { color: var(--danger); }
.mini-list { display: grid; gap: 7px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafb; color: inherit; text-align: left; }
.mini-row.static { cursor: default; }
.mini-row > span:first-child { min-width: 0; display: grid; gap: 2px; }
.mini-row strong { color: var(--navy); font-size: 13px; overflow-wrap: anywhere; }
.mini-row small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.mini-amount { flex: 0 0 auto; color: var(--navy); font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; }
.mini-go { flex: 0 0 auto; color: var(--teal); font-size: 12px; font-weight: 800; }
.attachment-list { display: grid; gap: 8px; }
.attachment-list a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 12px; border-radius: 12px; color: var(--navy); background: #f3f7f8; text-decoration: none; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(216, 225, 231, .92); background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px); }
.tab { min-width: 0; display: flex; flex-direction: column; align-items: center; border: 0; border-radius: 16px; padding: 8px 4px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 850; }
.tab strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab span,.tab strong { display: block; }
.tab span { margin-bottom: 2px; font-size: 18px; line-height: 1; }
.tab.active { color: var(--navy); background: #eaf2f4; }

.mcal-toolbar { gap: 6px; }
.mcal-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; }
.mcal-nav button { min-height: 44px; border: 1px solid var(--line); border-radius: 14px; padding: 9px 10px; color: var(--navy); background: white; font-size: 13px; font-weight: 800; }
.mcal-range { margin: 0; color: var(--muted); font-size: 12px; font-weight: 750; text-align: center; }
.mcal-days { display: grid; gap: 14px; }
.mcal-week { gap: 8px; }
.mcal-free-run { padding: 9px 12px; border: 1px dashed #c4d0d7; border-radius: 12px; color: #8a99a2; background: rgba(255, 255, 255, .5); font-size: 12px; font-weight: 700; text-align: center; }
.mcal-day { border-top: 1px solid var(--line); padding-top: 8px; scroll-margin-top: 150px; }
.mcal-day:first-of-type { border-top: 0; padding-top: 0; }
.mcal-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 2px 6px; }
.mcal-day-head strong { color: var(--navy); font-size: 13px; }
.mcal-day-head small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.mcal-day.weekend .mcal-day-head strong { color: var(--muted); }
.mcal-day.today .mcal-day-head strong,.mcal-day.today .mcal-day-head small { color: var(--teal); }
.mcal-day-body { display: grid; gap: 7px; }
.mcal-free { padding: 2px 2px 4px; color: #a5b3bc; font-size: 12px; }
.mcal-entry { width: 100%; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; color: inherit; background: #fbfcfd; text-align: left; }
.mcal-entry:active { transform: translateY(1px); }
.mcal-entry strong { color: var(--navy); font-size: 13.5px; line-height: 1.3; }
.mcal-entry small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.mcal-chip { justify-self: start; max-width: 100%; margin-top: 2px; padding: 3px 8px; border-radius: 999px; background: #dcefeb; color: var(--teal); font-size: 10.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcal-customer-day { border-color: #ecd9b3; background: #fdf6e7; }
.mcal-customer-day strong { color: #865b0b; font-size: 11px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.mcal-customer-day small { color: #9a7b3f; }
.mcal-open-project { width: 100%; }

@media (min-width: 760px) {
  .mobile-shell { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--paper); }
  .detail-dialog { width: min(760px, 100%); margin: 0 auto; }
}
