/* ============================================================
   COD CRM: Apple-style design
   SF Pro is used on Apple devices (system font). Other devices
   use Inter, the closest free match (Apple's licence does not
   allow putting SF Pro font files on a website).
   ============================================================ */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --bg: #f5f5f7; --card: #ffffff; --text: #1d1d1f; --muted: #6e6e73; --faint: #86868b;
  --line: rgba(0, 0, 0, .08); --fill: #e8e8ed; --fill-2: #f2f2f4;
  --blue: #0071e3; --blue-hover: #0077ed; --link: #0066cc;
  --green: #248a3d; --green-bg: #e3f6e8; --red: #d70015; --red-bg: #fde8ea;
  --orange: #c93400; --orange-bg: #fff1e0; --purple: #8944ab; --purple-bg: #f4eafa;
  --teal: #0071a4; --teal-bg: #e2f2fa; --gray-bg: #efeff1;
  --radius: 18px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-up: 0 2px 6px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.47; letter-spacing: -.01em;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--link); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-display); font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; margin: 6px 0 14px; }
h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 12px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--fill-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
pre { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: #1d1d1f; color: #f5f5f7; padding: 14px; border-radius: var(--radius-sm); overflow: auto; font-size: 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.pos { color: var(--green); } .neg { color: var(--red); } .nowrap { white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- navigation (frosted glass like apple.com) ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px; height: 52px; padding: 0 max(22px, calc((100vw - 1180px) / 2));
  background: rgba(251, 251, 253, .8); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 17px; color: var(--text); letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #0071e3, #5e5ce6); display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.top nav { display: flex; gap: 2px; flex: 1; }
.top nav a { padding: 6px 12px; border-radius: 980px; color: var(--text); opacity: .8; font-size: 13px; white-space: nowrap; }
.top nav a:hover { opacity: 1; text-decoration: none; }
.top nav a.on { opacity: 1; background: rgba(0, 0, 0, .06); font-weight: 500; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 22px 60px; }

/* iOS-style tab bar on phones */
.tabbar { display: none; }
@media (max-width: 760px) {
  .top nav { display: none; }
  .top { padding: 0 16px; height: 48px; justify-content: space-between; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(251, 251, 253, .86); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 500; color: var(--faint); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.on { color: var(--blue); }
  .tabbar .ico { width: 24px; height: 24px; }
  main { padding: 14px 14px 96px; }
  h1 { font-size: 28px; }
}

/* ---------- surfaces ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--green-bg); color: #1b6b2f; font-weight: 500; }
.flash.err { background: var(--red-bg); color: #a3000f; }
.flash.warn { background: var(--orange-bg); color: #8a3a00; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50; max-width: min(520px, 92vw); box-shadow: var(--shadow-up);
  background: rgba(29, 29, 31, .92); color: #fff; backdrop-filter: blur(20px); border-radius: 14px; display: none; }
.toast.err { background: rgba(215, 0, 21, .95); color: #fff; }

/* ---------- buttons (Apple pill buttons) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; min-height: 36px; border-radius: 980px; border: 0;
  background: var(--fill); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, transform .1s; }
.btn:hover { background: #dedee3; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); }
.btn.sm { padding: 5px 12px; min-height: 30px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--link); padding-left: 6px; padding-right: 6px; }
.btn.ghost:hover { background: transparent; text-decoration: underline; }
form { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- segmented controls ---------- */
.range, .tabs, .todo { display: flex; gap: 4px; align-items: center; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.range::-webkit-scrollbar, .tabs::-webkit-scrollbar, .todo::-webkit-scrollbar { display: none; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--fill); border-radius: 11px; flex: none; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 9px; color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.pill:hover { text-decoration: none; background: rgba(255, 255, 255, .5); }
.pill.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04); }
.pill small { color: var(--faint); font-weight: 500; margin-left: 2px; }
.range .custom { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; flex: none; }
.range input[type=date] { padding: 6px 10px; width: auto; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--card); box-shadow: var(--shadow); padding: 10px 16px; border-radius: 14px; color: var(--text); white-space: nowrap; font-weight: 500; }
.chip:hover { text-decoration: none; box-shadow: var(--shadow-up); }
.chip b { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi b { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.025em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi em { color: var(--faint); font-style: normal; font-size: 12px; }
.kpi.big { grid-column: span 2; background: linear-gradient(135deg, #1d1d1f, #3a3a3c); color: #fff; }
.kpi.big span, .kpi.big em { color: rgba(255, 255, 255, .7); }
.kpi.big b { font-size: 44px; }
.kpi.big b.pos { color: #30d158; } .kpi.big b.neg { color: #ff6961; }
.kpi.big .pos { color: #30d158; } .kpi.big .neg { color: #ff6961; }
.kpi small { font-size: 15px; color: inherit; opacity: .6; font-weight: 500; }
.chart { position: relative; height: 300px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: normal; min-width: 150px; font-weight: 500; }
.scroll { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 980px; font-size: 12px; font-weight: 600; background: var(--gray-bg); color: var(--muted); }
.tag.meta { background: #e8f0fe; color: #0866ff; } .tag.tiktok { background: #fde7ef; color: #e3105a; }
.tag.google { background: #fef4e2; color: #b26200; } .tag.organic { background: var(--green-bg); color: var(--green); }

.status { display: inline-block; padding: 3px 10px; border-radius: 980px; font-size: 12px; font-weight: 600; }
.s-new { background: #e8f0fe; color: var(--blue); } .s-no_answer { background: var(--orange-bg); color: var(--orange); }
.s-confirmed { background: var(--teal-bg); color: var(--teal); } .s-cancelled { background: var(--gray-bg); color: var(--muted); }
.s-shipped { background: var(--purple-bg); color: var(--purple); } .s-delivered { background: var(--green-bg); color: var(--green); }
.s-returned { background: var(--red-bg); color: var(--red); }

/* ---------- orders list ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.search { flex: 1; min-width: 200px; position: relative; }
.search input { width: 100%; padding-left: 36px; background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center / 16px; border-color: transparent; }
.list .row { padding: 0; margin-bottom: 10px; transition: box-shadow .15s; }
.list .row:hover { box-shadow: var(--shadow-up); }
.row-main { display: flex; justify-content: space-between; gap: 10px; padding: 16px 18px 8px; color: var(--text); }
.row-main:hover { text-decoration: none; }
.row-main b { font-weight: 600; }
.row-main .right { text-align: right; }
.row-main .right b { font-family: var(--font-display); font-size: 17px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 18px 14px; }
.grow { flex: 1; }
.pager { display: flex; justify-content: center; gap: 12px; align-items: center; }
.head { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #d2d2d7; border-radius: var(--radius-sm); background: #fff; color: var(--text); width: 100%; transition: border .15s, box-shadow .15s; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, .15); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 14px; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
label.check input { width: 20px; height: 20px; accent-color: var(--blue); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.form.inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form.inline label { margin: 0; flex: 1; min-width: 120px; }
.faded { opacity: .5; }
.paste textarea { margin-top: 10px; }
details summary { cursor: pointer; font-weight: 500; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform .2s; color: var(--faint); }
details[open] summary::before { transform: rotate(90deg); }
.sticky-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); z-index: 5; }
@media (max-width: 760px) { .sticky-save { bottom: 64px; } }

.login { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(1200px 600px at 50% -20%, #dfe9ff, var(--bg)); }
.login-card { width: min(380px, 92vw); padding: 32px; text-align: center; }
.login-card .logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; font-size: 24px; }
.login-card label { text-align: left; }

/* ---------- reports ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { margin: 0; flex: 1; min-width: 130px; }
.filters .grow2 { flex: 2; min-width: 200px; }
.selected { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm); background: #e8f0fe; color: var(--text); }
table.report a.sort { color: var(--muted); }
table.report a.sort:hover { color: var(--text); text-decoration: none; }
table.report a.sort.on { color: var(--blue); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--fill-2); }
tr.sel td { background: #e8f0fe; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.rate { display: inline-block; min-width: 52px; padding: 2px 8px; border-radius: 980px; text-align: center;
  background: linear-gradient(90deg, var(--green-bg) var(--p), var(--red-bg) var(--p)); font-weight: 600; font-size: 12px; }
.mapping td { vertical-align: middle; }
.mapping select { min-width: 180px; }
.hint { font-size: 12px; color: var(--faint); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 12px; }
.steps li { counter-increment: s; position: relative; padding: 0 0 10px 34px; font-size: 14px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--fill); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.connected { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; font-size: 14px; }
.connected::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #34c759; }

@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi b { font-size: 24px; }
  .kpi.big b { font-size: 36px; }
  .card { padding: 16px; border-radius: 16px; }
  .range .custom { margin-left: 0; }
  .toast { bottom: 90px; }
}

/* Claude */
.claude { background: linear-gradient(135deg, #fff7f2, #ffffff 60%); }
.claude-mark { color: #d97757; font-size: 20px; margin-right: 4px; }
.note { padding: 12px 0; border-top: 1px solid var(--line); }
.note:first-of-type { border-top: 0; }
.note p { margin: 4px 0; white-space: pre-line; font-size: 14px; }
.note.alert b { color: var(--red); }
