/* Itinerary Creator — market-grade trip planner. Namespaced under .ic */
:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; }
.ic {
    --bg: #f6f8fb; --panel: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e6ebf1;
    --brand: #0284c7; --brand-ink: #0369a1; --accent: #f59e0b; --ok: #16a34a; --danger: #ef4444;
    --shadow: 0 12px 32px -18px rgba(15,23,42,.35);
    min-height: calc(100vh - 44px);
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    background:
        radial-gradient(1000px 420px at 90% -10%, rgba(2,132,199,.08), transparent),
        radial-gradient(900px 400px at 0% 110%, rgba(245,158,11,.08), transparent),
        var(--bg);
    color: var(--ink);
}

/* Buttons */
.ic-btn { border: 0; cursor: pointer; border-radius: .6rem; padding: .55rem .9rem; font: 600 .88rem inherit;
    background: var(--brand); color: #fff; transition: transform .1s ease, background .15s, box-shadow .15s; white-space: nowrap; }
.ic-btn:hover { transform: translateY(-1px); }
.ic-btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.ic-btn.ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.ic-btn.ghost.danger { color: var(--danger); }
.ic-btn.ghost.danger:hover { border-color: var(--danger); }
.ic-btn.xs { padding: .4rem .7rem; font-size: .8rem; background: #eef4f9; color: var(--brand-ink); }
.ic-btn.xs:hover { background: #e0eefb; }
.ic-btn.xs.ghost { background: var(--panel); }

/* Top bar */
.ic-topbar { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.5rem; background: var(--panel);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; flex-wrap: wrap; }
.ic-brand { display: flex; align-items: center; gap: .7rem; }
.ic-logo { font-size: 1.7rem; filter: drop-shadow(0 4px 8px rgba(2,132,199,.3)); }
.ic-title { font: 800 1.15rem inherit; border: 0; background: transparent; color: var(--ink); letter-spacing: -.02em;
    border-bottom: 1.5px dashed transparent; padding: 0 0 1px; width: 15rem; max-width: 40vw; }
.ic-title:focus { outline: 0; border-bottom-color: var(--brand); }
.ic-sub { color: var(--muted); font-size: .82rem; }
.ic-stats { display: flex; gap: 1.2rem; margin-left: auto; }
.ic-stat { text-align: center; }
.ic-stat b { display: block; font-size: 1.05rem; font-weight: 800; color: var(--brand-ink); line-height: 1.1; }
.ic-stat small { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
.ic-topbar-actions { display: flex; align-items: center; gap: .5rem; }
.ic-saved { font-size: .75rem; color: var(--ok); font-weight: 600; opacity: 0; transition: opacity .3s; }
.ic-saved.show { opacity: 1; }
.ic-menu { position: relative; }
.ic-menu-pop { position: absolute; right: 0; top: calc(100% + .4rem); background: var(--panel); border: 1px solid var(--line);
    border-radius: .7rem; box-shadow: var(--shadow); padding: .3rem; display: flex; flex-direction: column; min-width: 12rem; z-index: 50; }
.ic-menu-pop[hidden] { display: none; }
.ic-menu-pop button { border: 0; background: transparent; text-align: left; padding: .55rem .7rem; border-radius: .5rem;
    font: 600 .85rem inherit; cursor: pointer; color: var(--ink); }
.ic-menu-pop button:hover { background: #f1f5f9; }

/* Body grid */
.ic-body { display: grid; grid-template-columns: 300px 1fr 380px; gap: 1.25rem; max-width: 1500px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; align-items: start; }
@media (max-width: 1180px) { .ic-body { grid-template-columns: 280px 1fr; } .ic-side { grid-column: 1 / -1; } }
@media (max-width: 780px) { .ic-body { grid-template-columns: 1fr; } .ic-rail, .ic-side { grid-column: auto; } }

/* Cards */
.ic-card, .ic-map-card, .ic-extras { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.ic-rail { display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: 76px; }
@media (max-width: 780px) { .ic-rail { position: static; } }
.ic-card { padding: 1.1rem; }
.ic-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.ic-card-head h3 { margin: 0; font-size: .95rem; }
.ic-chip { font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: #ecfdf5; color: var(--ok); }
.ic-chip.over { background: #fef2f2; color: var(--danger); }

/* Fields */
.ic-field { display: flex; flex-direction: column; gap: .3rem; font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: .7rem; }
.ic-field:last-child { margin-bottom: 0; }
.ic-field span { text-transform: uppercase; letter-spacing: .03em; font-size: .68rem; }
.ic-field input, .ic-field select, .ic-field textarea { font: 400 .9rem inherit; padding: .55rem .65rem; border: 1px solid var(--line);
    border-radius: .55rem; background: #f8fafc; color: var(--ink); }
.ic-field input:focus, .ic-field select:focus, .ic-field textarea:focus { outline: 0; border-color: var(--brand); background: var(--panel); }
.ic-field-row { display: flex; gap: .6rem; }
.ic-field-row .ic-field { flex: 1; }
.ic-field-sm { max-width: 6.5rem; }

/* Budget */
.ic-budget-bar { height: 9px; background: #eef2f7; border-radius: 999px; overflow: hidden; margin-bottom: .5rem; }
.ic-budget-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), #22c55e); width: 0; transition: width .4s ease, background .3s; border-radius: 999px; }
.ic-budget-bar i.over { background: linear-gradient(90deg, #f97316, var(--danger)); }
.ic-budget-nums { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.ic-budget-nums b { color: var(--ink); }
.ic-donut { width: 96px; height: 96px; display: block; margin: 1rem auto .5rem; }
.ic-donut-legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; justify-content: center; font-size: .74rem; color: var(--muted); }
.ic-donut-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.ic-donut-legend i { width: .65rem; height: .65rem; border-radius: 3px; }

/* Templates */
.ic-templates { display: flex; flex-direction: column; gap: .5rem; }
.ic-template { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: .7rem;
    cursor: pointer; background: #f8fafc; transition: border-color .15s, transform .1s; text-align: left; }
.ic-template:hover { border-color: var(--brand); transform: translateY(-1px); }
.ic-template .e { font-size: 1.4rem; }
.ic-template b { display: block; font-size: .85rem; }
.ic-template small { color: var(--muted); font-size: .72rem; }

/* Centre */
.ic-center { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ic-days-tabs { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.ic-day-tab { border: 1px solid var(--line); background: var(--panel); border-radius: .7rem; padding: .5rem .8rem; cursor: pointer;
    font: 600 .85rem inherit; color: var(--ink); display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; transition: border-color .15s; }
.ic-day-tab:hover { border-color: var(--brand); }
.ic-day-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.ic-day-tab small { font-size: .68rem; opacity: .8; }
.ic-day-tab.overview { justify-content: center; }
.ic-day-add { border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: .7rem; padding: .5rem .7rem;
    cursor: pointer; font: 700 .95rem inherit; }
.ic-day-add:hover { border-color: var(--brand); color: var(--brand); }

.ic-day-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ic-day-summary { font-size: .82rem; color: var(--muted); }
.ic-day-summary b { color: var(--ink); }
.ic-daylink { border: 0; background: transparent; color: var(--brand-ink); cursor: pointer; font: 600 .78rem inherit; padding: 0 .2rem; }
.ic-daylink:hover { text-decoration: underline; }
.ic-day-tools { display: flex; gap: .4rem; flex-wrap: wrap; }

.ic-addbar { position: relative; display: flex; align-items: center; gap: .5rem; background: var(--panel); border: 1px solid var(--line);
    border-radius: .8rem; padding: .1rem .8rem; box-shadow: var(--shadow); }
.ic-search-ic { color: var(--muted); }
.ic-addbar input { flex: 1; border: 0; background: transparent; font: 400 .92rem inherit; padding: .75rem .3rem; color: var(--ink); }
.ic-addbar input:focus { outline: 0; }
.ic-suggest-pop { position: absolute; left: 0; right: 0; top: calc(100% + .3rem); background: var(--panel); border: 1px solid var(--line);
    border-radius: .8rem; box-shadow: var(--shadow); z-index: 30; max-height: 320px; overflow: auto; padding: .3rem; }
.ic-suggest-pop[hidden] { display: none; }
.ic-poi { display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem; border-radius: .6rem; cursor: pointer; }
.ic-poi:hover, .ic-poi.hl { background: #f1f5f9; }
.ic-poi .e { width: 2rem; height: 2rem; border-radius: .5rem; display: grid; place-items: center; font-size: 1.1rem; color: #fff; flex: none; }
.ic-poi .info { flex: 1; min-width: 0; }
.ic-poi .info b { font-size: .88rem; display: block; }
.ic-poi .info small { color: var(--muted); font-size: .74rem; }
.ic-poi .meta { text-align: right; font-size: .74rem; color: var(--muted); }
.ic-poi .meta .r { color: var(--accent); font-weight: 700; }

/* Stops */
.ic-stops { display: flex; flex-direction: column; gap: .1rem; }
.ic-stop { position: relative; display: flex; gap: .8rem; align-items: stretch; }
.ic-stop-rail { display: flex; flex-direction: column; align-items: center; width: 3.2rem; flex: none; padding-top: .9rem; }
.ic-stop-time { font-size: .74rem; font-weight: 700; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.ic-stop-line { width: 2px; flex: 1; background: var(--line); margin: .3rem 0; }
.ic-stop:last-child .ic-stop-line { background: transparent; }
.ic-stop-card { flex: 1; margin: .35rem 0; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--cat, var(--brand));
    border-radius: .8rem; padding: .8rem .9rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: .8rem; cursor: grab; transition: box-shadow .15s, transform .1s, border-color .15s; }
.ic-stop-card:hover { border-color: var(--cat, var(--brand)); }
.ic-stop-card.dragging { opacity: .5; }
.ic-stop-card.drop-target { transform: translateY(2px); box-shadow: 0 0 0 2px var(--brand) inset; }
.ic-stop.hl .ic-stop-card { box-shadow: 0 0 0 2px var(--brand); }
.ic-stop-handle { color: #cbd5e1; cursor: grab; font-size: 1.1rem; line-height: 1; }
.ic-stop-emoji { width: 2.4rem; height: 2.4rem; border-radius: .6rem; display: grid; place-items: center; font-size: 1.2rem; color: #fff; background: var(--cat, var(--brand)); flex: none; }
.ic-stop-main { flex: 1; min-width: 0; }
.ic-stop-main b { font-size: .95rem; display: block; }
.ic-stop-tags { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; font-size: .74rem; color: var(--muted); }
.ic-stop-tags .cat-tag { color: var(--cat, var(--brand)); font-weight: 700; }
.ic-stop-cost { text-align: right; font-size: .82rem; }
.ic-stop-cost b { color: var(--ink); }
.ic-stop-cost small { display: block; color: var(--muted); font-size: .7rem; }
.ic-stop-del { border: 0; background: transparent; color: #cbd5e1; cursor: pointer; font-size: 1.1rem; }
.ic-stop-del:hover { color: var(--danger); }
.ic-empty-day { text-align: center; color: var(--muted); padding: 2.5rem 1rem; border: 1px dashed var(--line); border-radius: .9rem; }
.ic-empty-day b { display: block; color: var(--ink); margin-bottom: .3rem; }

/* Overview */
.ic-overview { display: flex; flex-direction: column; gap: .8rem; }
.ic-ov-day { background: var(--panel); border: 1px solid var(--line); border-radius: .8rem; padding: .9rem 1rem; box-shadow: var(--shadow); }
.ic-ov-day h4 { margin: 0 0 .5rem; font-size: .95rem; display: flex; justify-content: space-between; }
.ic-ov-day h4 span { color: var(--muted); font-size: .78rem; font-weight: 500; }
.ic-ov-stop { display: flex; gap: .6rem; font-size: .84rem; padding: .2rem 0; color: var(--muted); }
.ic-ov-stop b { color: var(--ink); font-weight: 600; }

/* Right side: map */
.ic-side { display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: 76px; }
@media (max-width: 1180px) { .ic-side { position: static; } }
.ic-map-card { padding: 1rem; }
.ic-map-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.ic-map-head strong { font-size: .95rem; }
#ic-map { width: 100%; height: auto; aspect-ratio: 1; background: linear-gradient(180deg, #e8f2fb, #eafaf1); border-radius: .8rem; display: block; }
.ic-map-pin { cursor: pointer; }
.ic-map-pin text { font-size: 22px; font-weight: 800; fill: #fff; }
.ic-legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; margin-top: .7rem; font-size: .74rem; color: var(--muted); }
.ic-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.ic-legend i { width: .7rem; height: .7rem; border-radius: 50%; }

/* Extras */
.ic-extras { overflow: hidden; }
.ic-extra-tabs { display: flex; border-bottom: 1px solid var(--line); }
.ic-extra-tab { flex: 1; border: 0; background: transparent; padding: .7rem; font: 600 .82rem inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.ic-extra-tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.ic-extra-body { padding: 1rem; }
.ic-weather { display: flex; flex-direction: column; gap: .5rem; }
.ic-weather-row { display: flex; align-items: center; gap: .7rem; font-size: .85rem; }
.ic-weather-row .e { font-size: 1.4rem; }
.ic-weather-row b { flex: 1; }
.ic-weather-row small { color: var(--muted); }
.ic-packing { display: flex; flex-direction: column; gap: .35rem; }
.ic-pack-item { display: flex; align-items: center; gap: .5rem; font-size: .85rem; cursor: pointer; }
.ic-pack-item input { accent-color: var(--brand); }
.ic-pack-item.done span { text-decoration: line-through; color: var(--muted); }
.ic-pack-add { display: flex; gap: .4rem; margin-top: .5rem; }
.ic-pack-add input { flex: 1; font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .5rem; }
.ic-notes-area { width: 100%; min-height: 140px; font: inherit; padding: .7rem; border: 1px solid var(--line); border-radius: .6rem; resize: vertical; }

/* Modal */
.ic-modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 120; padding: 1rem; }
.ic-modal-overlay[hidden] { display: none; }
.ic-modal-card { background: var(--panel); border-radius: 1.1rem; padding: 1.6rem; width: min(30rem, 100%); position: relative; box-shadow: var(--shadow); }
.ic-modal-close { position: absolute; top: 1rem; right: 1.2rem; border: 0; background: transparent; font-size: 1.4rem; cursor: pointer; color: #94a3b8; }
.ic-modal-card h3 { margin: 0 0 1.1rem; }
.ic-modal-actions { display: flex; justify-content: space-between; gap: .6rem; margin-top: .5rem; }

/* Toast */
.ic-toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff;
    padding: .7rem 1.1rem; border-radius: .7rem; font-size: .88rem; box-shadow: 0 15px 40px -12px rgba(0,0,0,.5); z-index: 200; max-width: 90vw; }
.ic-toast[hidden] { display: none; }

/* Print / PDF */
@media print {
    .demo-chrome, .ic-topbar-actions, .ic-rail, .ic-side, .ic-days-tabs, .ic-day-tools, .ic-addbar, .ic-stop-handle, .ic-stop-del { display: none !important; }
    .ic { background: var(--panel); }
    .ic-body { display: block; max-width: none; padding: 0; }
    .ic-center { gap: .5rem; }
    .ic-stop-card { box-shadow: none; break-inside: avoid; }
    body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ic-print-only { display: block !important; }
}
.ic-print-only { display: none; }
