/* App frame, period bar, KPI row, charts, cards, calendar, map, login. */

.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100dvh; }

.rail {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgb(18 20 27 / .96), rgb(11 12 17 / .96));
  padding: 14px 10px; display: flex; flex-direction: column; gap: 14px;
}
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; border-bottom: 1px solid var(--line); }
.brand-hex { color: var(--mint); text-shadow: 0 0 12px rgb(159 216 203 / .7); font-size: 16px; }
.brand-name { font: 600 15px var(--mono); letter-spacing: .22em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; color: var(--muted); font-size: 13.5px; position: relative;
  transition: color .15s, background .15s;
}
.nav-item:hover { color: var(--text); background: rgb(159 216 203 / .04); }
.nav-item.on { color: var(--text); background: linear-gradient(90deg, rgb(159 216 203 / .12), transparent); }
.nav-item.on::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.nav-icon { width: 18px; text-align: center; color: var(--dim); font-size: 14px; }
.nav-item.on .nav-icon { color: var(--mint); }
.nav-text { flex: 1; }
.nav-code { font-size: 9px; }
.nav-item.more { display: none; }

.main { padding: 18px 24px 40px; min-width: 0; }
.screen.enter { animation: enter .22s var(--ease); }
.stack { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

.period-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px;
  margin-bottom: 16px; padding: 8px 10px;
  border: 1px solid var(--line); background: rgb(18 20 27 / .8);
  position: sticky; top: 0; z-index: 5; backdrop-filter: none;
}
.segmented { display: flex; border: 1px solid var(--line-hi); }
.seg { padding: 6px 12px; font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-right: 1px solid var(--line); transition: color .15s, background .15s; }
.seg:last-child { border-right: 0; }
.seg:hover { color: var(--text); }
.seg.on { color: var(--bg); background: var(--mint); box-shadow: 0 0 14px rgb(159 216 203 / .35); }
.period-nav { display: flex; align-items: center; gap: 8px; }
.period-title { font-size: 15px; font-weight: 600; min-width: 190px; text-align: center; }

.kpis { display: grid; grid-template-columns: 1.35fr repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  min-width: 0;
}
.kpi strong { font-size: 20px; font-weight: 500; }
.kpi strong.big { font-size: 28px; }
.kpi.main { background: linear-gradient(135deg, rgb(184 207 160 / .10), rgb(159 216 203 / .05) 60%, var(--panel)); border-color: rgb(159 216 203 / .3); }
.kpi.main strong.pos { text-shadow: 0 0 18px rgb(184 207 160 / .35); }
.kpi .delta { position: absolute; top: 10px; right: 10px; }
.kpi .split { display: grid; gap: 1px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi .split b { color: var(--text); font-weight: 500; }

.chart { position: relative; padding: 10px 12px 8px; }
.money-chart { width: 100%; height: auto; display: block; }
.money-chart .axis { stroke: var(--line); stroke-width: 1; }
.money-chart .axis.zero { stroke: var(--line-hi); }
.money-chart .tick { fill: var(--dim); font: 10px var(--mono); }
.money-chart .hit { fill: transparent; }
.money-chart .slot.pickable { cursor: pointer; }
.money-chart .slot:hover .hit { fill: rgb(159 216 203 / .05); }
.money-chart .bar.revenue { fill: var(--mint); opacity: .85; }
.money-chart .bar.cost { fill: var(--pink); opacity: .55; }
.money-chart .profit-line { fill: none; stroke: var(--lavender); stroke-width: 1.6; filter: drop-shadow(0 0 3px rgb(183 168 224 / .6)); }
.money-chart .dot { fill: var(--lavender); }
.money-chart .dot.neg { fill: var(--pink); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 4px 6px 4px 56px; font: 11px var(--mono); color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.legend .l-revenue::before { background: var(--mint); }
.legend .l-cost::before { background: var(--pink); opacity: .7; }
.legend .l-profit::before { height: 2px; vertical-align: 3px; background: var(--lavender); }
.legend .hint::before { display: none; }
.chart-tip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 170px;
  display: grid; gap: 2px; padding: 8px 10px; font-size: 12px;
  background: rgb(11 12 17 / .95); border: 1px solid var(--line-hi); box-shadow: 0 0 16px rgb(183 168 224 / .15);
}
.chart-tip span { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.chart-tip i { font-style: normal; color: var(--text); }

.donut { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; padding: 14px 16px; }
.donut-svg { width: 150px; height: 150px; transform: rotate(-90deg); }
.donut-svg text { transform: rotate(90deg); transform-origin: 70px 70px; }
.donut .track { fill: none; stroke: var(--inset); stroke-width: 14; }
.donut .arc { fill: none; stroke: var(--c); stroke-width: 14; }
.donut-title { fill: var(--muted); font: 9px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.donut-value { fill: var(--text); font: 500 14px var(--mono); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; min-width: 0; }
.donut-legend li { display: grid; grid-template-columns: 12px 1fr auto 40px; gap: 8px; align-items: center; }
.donut-legend small { color: var(--dim); text-align: right; }

/* Detail header. */
.detail-head {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
  padding: 18px 20px; border: 1px solid var(--line);
  background: linear-gradient(120deg, rgb(183 168 224 / .08), rgb(159 216 203 / .04) 50%, rgb(18 20 27 / .9));
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);

}
.detail-title { display: grid; gap: 6px; min-width: 0; }
.detail-title h1 { font-size: 24px; font-weight: 600; letter-spacing: .01em; }
.detail-lines { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
.detail-lines .span { font-size: 15px; color: var(--mint); }
.detail-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.compare-note { font-size: 12px; color: var(--dim); margin-top: -6px; }

/* Cards. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 14px 16px 16px; }
.card, .placement {
  position: relative; display: grid; gap: 10px; padding: 14px;
  background: var(--inset); border: 1px solid var(--line);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: border-color .15s, transform .15s var(--ease), box-shadow .15s;
}
a.card:hover { border-color: rgb(159 216 203 / .55); transform: translateY(-2px); box-shadow: 0 6px 24px rgb(159 216 203 / .08); }
.card-top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.card-title { display: grid; gap: 2px; min-width: 0; }
.card-title strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .dim { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-figures { display: grid; grid-template-columns: 1.2fr 1fr .6fr; gap: 8px; }
.card-figures div { display: grid; gap: 2px; }
.card-figures .label { font-size: 9.5px; }
.card-foot { font-size: 11.5px; }
.spark { width: 100%; height: 28px; }
.spark polyline { fill: none; stroke: var(--lavender); stroke-width: 1.3; vector-effect: non-scaling-stroke; }
.share { display: grid; gap: 4px; }
.share i { display: block; height: 3px; background: linear-gradient(90deg, var(--mint), var(--lavender)); }
.share small { color: var(--dim); font-size: 11px; }
.placement-rent { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.placement-actions { display: flex; gap: 8px; }

/* Festival lists. */
.event-list { list-style: none; margin: 0; padding: 6px 0; }
.event { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid rgb(37 42 55 / .6); }
.event:last-child { border-bottom: 0; }
.event.clickable { cursor: pointer; }
.event.clickable:hover { background: rgb(159 216 203 / .04); }
.event-date { display: grid; gap: 4px; justify-items: start; }
.event-body { display: grid; gap: 3px; min-width: 0; }
.event-attractions { display: flex; gap: 4px; margin-top: 2px; }
.event-money { display: grid; justify-items: end; font-size: 13px; }
.event-money small { color: var(--dim); font-size: 10.5px; }
.month-groups { display: grid; }
.month-group { display: grid; grid-template-columns: 110px 1fr; border-bottom: 1px solid var(--line); }
.month-label { padding: 14px 16px; display: grid; align-content: start; gap: 2px; border-right: 1px solid var(--line); }
.month-label span { font-size: 14px; text-transform: capitalize; }
.month-label small { color: var(--dim); font-size: 11px; }
.festival-list { list-style: none; margin: 0; padding: 0; }
.festival-line { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 14px; align-items: center; padding: 11px 16px; border-bottom: 1px solid rgb(37 42 55 / .6); cursor: pointer; }
.festival-line:last-child { border-bottom: 0; }
.festival-line:hover { background: rgb(159 216 203 / .04); }
.fl-main { display: grid; gap: 4px; justify-items: start; }
.fl-where { display: grid; gap: 2px; font-size: 13px; }
.fl-attractions { display: flex; flex-wrap: wrap; gap: 4px; }
.fl-money { display: grid; justify-items: end; gap: 2px; }
.fl-money small { font-size: 11px; }
.tag { font-size: 11px; padding: 2px 7px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); white-space: nowrap; }

/* Festival day grid and the owner's table. */
table.days tr.weekend td { background: rgb(183 168 224 / .035); }
.cell-edit { cursor: pointer; }
.cell-edit:hover { background: rgb(159 216 203 / .08); outline: 1px solid rgb(159 216 203 / .3); outline-offset: -1px; }
.cell-edit .add { color: var(--dim); }
.weather { white-space: nowrap; }
.sheet-like table.journal td, .sheet-like table.journal th { border-right: 1px solid rgb(37 42 55 / .6); white-space: nowrap; }
.month-cell { width: 34px; padding: 0 !important; background: rgb(183 168 224 / .06); border-right: 1px solid var(--line-hi) !important; }
.month-cell span { display: block; writing-mode: vertical-rl; transform: rotate(180deg); margin: 8px auto; font: 500 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--lavender); }
.journal tbody { border-bottom: 1px solid var(--line-hi); }
.tick { width: 16px; height: 16px; border: 1px solid var(--line-hi); display: inline-grid; place-items: center; vertical-align: middle; }
.tick.on { border-color: var(--sage); background: rgb(184 207 160 / .2); }
.tick.on::after { content: ""; width: 8px; height: 8px; background: var(--sage); }

/* Debts. */
.debts { display: grid; gap: 12px; padding: 14px 16px; }
.debt-total { display: flex; justify-content: space-between; align-items: baseline; }
.debt-total strong { font-size: 22px; font-weight: 500; }
.debt-group h3 { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.debt-line { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; }
.plain { list-style: none; margin: 0; padding: 10px 16px; display: grid; gap: 6px; }

/* Calendar. */
.calendar { border: 1px solid var(--line); background: var(--panel); }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-head span { padding: 8px 10px; font: 500 10.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); min-height: 92px; row-gap: 3px; }
.cal-week:last-child { border-bottom: 0; }
.cal-day { border-right: 1px solid rgb(37 42 55 / .7); padding: 6px 8px; display: flex; justify-content: space-between; align-items: flex-start; gap: 4px; text-align: left; transition: background .12s; }
.cal-day:nth-child(7) { border-right: 0; }
.cal-day:hover { background: rgb(159 216 203 / .04); }
.cal-day.other { opacity: .35; }
.cal-day.weekend { background: rgb(183 168 224 / .03); }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--mint); }
.cal-day.today .cal-num { color: var(--mint); }
.cal-num { font: 500 12px var(--mono); }
.cal-money { font-size: 10px; color: var(--sage); }
.cal-bar {
  z-index: 1; margin: 0 4px; padding: 0 8px; display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 11.5px; color: var(--bg); font-weight: 600;
  background: color-mix(in srgb, var(--c) 85%, transparent);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: filter .15s;
}
.cal-bar:hover { filter: brightness(1.15) drop-shadow(0 0 6px var(--c)); }
.cal-bar.cont-l { margin-left: 0; clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }
.cal-bar.cont-r { margin-right: 0; clip-path: polygon(6px 0, 100% 0, 100% 100%, 0 100%); }
.cal-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.cal-dots { display: flex; gap: 3px; flex: none; }
.cal-dots i { width: 7px; height: 7px; background: var(--c); border: 1px solid var(--bg); transform: rotate(45deg); }
.event-body .sw { vertical-align: 1px; }

/* Map. */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.map-frame { position: relative; border: 1px solid var(--line); padding: 4px; background: var(--panel); }
.map-host { height: min(70dvh, 640px); background: #0d0e13; }
.map-frame .corner { z-index: 500; }
.leaflet-container { background: #0d0e13; font: inherit; }
.leaflet-control-attribution { background: rgb(11 12 17 / .7) !important; color: var(--dim) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--raised) !important; color: var(--text) !important; border-color: var(--line) !important; }
.map-tooltip { background: rgb(11 12 17 / .95) !important; border: 1px solid var(--line-hi) !important; color: var(--text) !important; box-shadow: 0 0 16px rgb(159 216 203 / .15) !important; border-radius: 0 !important; }
.map-tooltip::before { display: none; }
.map-tip { display: grid; gap: 2px; font-size: 12px; }
.map-tip span { color: var(--muted); }

/* Login and boot. */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-box {
  position: relative; width: min(360px, 100%); display: grid; gap: 12px; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line-hi); box-shadow: 0 0 50px rgb(183 168 224 / .1);
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  animation: boot .4s var(--ease);
}
.brand-big { font: 600 26px var(--mono); letter-spacing: .3em; display: flex; gap: 12px; align-items: center; }
.login-status { min-height: 18px; color: var(--pink); font-size: 13px; }
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; grid-column: 1 / -1; }
.boot .brand-hex { font-size: 28px; animation: pulse 1.2s infinite; }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.main { grid-column: span 3; }
  .festival-line { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }
  .fl-attractions { display: none; }
}
@media (max-width: 1100px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .map-layout { grid-template-columns: minmax(0, 1fr); }
}
.screen.enter .detail-head { animation: boot .35s var(--ease); }
.map-host .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.82) contrast(.88) saturate(.35); }
.map-host .leaflet-container, .map-host.leaflet-container { background: #14161d; }
