:root {
  --bg: #ffffff;
  --bg2: #fafafa;
  --card: #ffffff;
  --text: #0f0f10;
  --muted: #737373;
  --line: #dbdbdb;
  --line2: #efefef;
  --accent: #e1306c;
  --blue: #0095f6;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #ed4956;
  --grad: linear-gradient(45deg, #ffb340 0%, #ff4f6d 45%, #c13584 70%, #7a3ff2 100%);
  --grad-soft: linear-gradient(45deg, #fff1df, #ffe3ea, #f1e6ff);
  --radius: 14px;
  --nav-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --bg2: #0c0c0d;
    --card: #121214;
    --text: #f5f5f5;
    --muted: #a8a8a8;
    --line: #363636;
    --line2: #262626;
    --grad-soft: linear-gradient(45deg, #2a1d10, #2a1219, #1d1430);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #000000;
  --bg2: #0c0c0d;
  --card: #121214;
  --text: #f5f5f5;
  --muted: #a8a8a8;
  --line: #363636;
  --line2: #262626;
  --grad-soft: linear-gradient(45deg, #2a1d10, #2a1219, #1d1430);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }

/* ------------------------------------------------------------- шапка --- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line2);
}
.top h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .logo { font-family: 'Billabong', 'Brush Script MT', 'Segoe Script', cursive; font-weight: 400; font-size: 28px; }
.top .back { border: 0; background: none; font-size: 26px; padding: 0 6px 0 0; cursor: pointer; line-height: 1; }
.top .icon-btn { border: 0; background: none; font-size: 22px; cursor: pointer; padding: 6px; }

main { max-width: 640px; margin: 0 auto; padding: 0 0 16px; }
main.wide { max-width: 1400px; }
.pad { padding: 0 16px; }
.section-title { font-weight: 700; font-size: 16px; margin: 20px 16px 8px; display: flex; align-items: center; gap: 8px; }
.section-title .sub { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.hide { display: none !important; }

/* ------------------------------------------------------ «сторіс» --- */
.stories { display: flex; gap: 14px; overflow-x: auto; padding: 14px 16px 10px; scrollbar-width: none; border-bottom: 1px solid var(--line2); }
.stories::-webkit-scrollbar { display: none; }
.story { flex: 0 0 auto; width: 66px; text-align: center; cursor: pointer; border: 0; background: none; padding: 0; }
.story .ring { width: 66px; height: 66px; border-radius: 50%; padding: 2.5px; background: var(--line); margin: 0 auto; }
.story.on .ring { background: var(--grad); }
.story.warn .ring { background: linear-gradient(45deg, #ffcc33, #ff8a00); }
.story.bad .ring { background: linear-gradient(45deg, #ff5f6d, #c21500); }
.story .ring > div {
  width: 100%; height: 100%; border-radius: 50%; background: var(--bg); border: 2.5px solid var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
.story .big { font-weight: 700; font-size: 17px; }
.story .tiny { font-size: 10px; color: var(--muted); }
.story .cap { display: block; margin-top: 5px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story.today .cap { font-weight: 700; }

/* ----------------------------------------------------------- профіль --- */
.profile { display: flex; align-items: center; gap: 22px; padding: 18px 16px 6px; }
.avatar {
  flex: 0 0 auto; width: 84px; height: 84px; border-radius: 50%; padding: 3px; background: var(--grad);
}
.avatar > div {
  width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--bg); background: var(--bg2);
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700;
}
.avatar.sm { width: 40px; height: 40px; padding: 2px; }
.avatar.sm > div { border-width: 2px; font-size: 14px; }
.stats { flex: 1; display: flex; justify-content: space-around; text-align: center; }
.stats b { display: block; font-size: 18px; }
.stats span { font-size: 13px; color: var(--muted); }
.bio { padding: 4px 16px 12px; }
.bio b { display: block; }

/* ------------------------------------------------------------ картки --- */
.card { background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius); margin: 10px 16px; padding: 14px; }
.card.flat { border: 0; background: var(--bg2); }
.card.grad { background: var(--grad-soft); border: 0; }
.hero-num { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 16px; }
.kpi { background: var(--bg2); border-radius: 12px; padding: 12px 10px; text-align: center; }
.kpi b { display: block; font-size: 19px; }
.kpi span { font-size: 12px; color: var(--muted); }

.list { margin: 0; padding: 0; list-style: none; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line2); cursor: default; }
.item.link { cursor: pointer; }
.item.link:active { background: var(--bg2); }
.item .t { font-weight: 600; }
.item .s { font-size: 13px; color: var(--muted); }
.item .amt { font-weight: 700; white-space: nowrap; text-align: right; }
.item.cancelled { opacity: 0.45; }
.item.cancelled .amt { text-decoration: line-through; }
.day-head { padding: 14px 16px 4px; font-weight: 700; display: flex; }
.day-head span { margin-left: auto; color: var(--muted); font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg2); color: var(--muted); border: 1px solid var(--line2); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.grad { background: var(--grad); color: #fff; border: 0; }

.progress { height: 6px; border-radius: 999px; background: var(--line2); overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; }
.progress.bad > i { background: var(--bad); }

/* ----------------------------------------------------------- кнопки --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer;
  background: var(--blue); color: #fff; min-height: 40px;
}
.btn.grad { background: var(--grad); }
.btn.ghost { background: var(--bg2); color: var(--text); border: 1px solid var(--line2); }
.btn.danger { background: var(--bad); }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 6px 12px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 16px; }

.scan-hero { display: flex; flex-direction: column; align-items: center; padding: 26px 16px 8px; }
.scan-big {
  width: 172px; height: 172px; border-radius: 50%; border: 0; cursor: pointer; padding: 5px; background: var(--grad);
  box-shadow: 0 10px 30px -10px rgba(225, 48, 108, 0.55);
}
.scan-big > div {
  width: 100%; height: 100%; border-radius: 50%; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; font-weight: 700; font-size: 16px;
}
.scan-big .ico { font-size: 52px; line-height: 1; }
.scan-big:active { transform: scale(0.97); }

/* ------------------------------------------------------------ форми --- */
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 10px 12px; min-height: 42px; outline: none;
}
.input:focus { border-color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.check { display: flex; gap: 10px; align-items: center; padding: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 3px; margin: 10px 16px; border: 1px solid var(--line2); }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.search { margin: 10px 16px; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 16px 0; }
.month-nav button { border: 0; background: var(--bg2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.month-nav b { min-width: 150px; text-align: center; text-transform: capitalize; }

/* ----------------------------------------------------------- таблиці --- */
.table-wrap { overflow: auto; margin: 10px 16px; border: 1px solid var(--line2); border-radius: 12px; max-height: calc(100vh - 220px); }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; text-align: right; background: var(--card); }
table.t th { position: sticky; top: 0; z-index: 2; background: var(--bg2); font-weight: 600; color: var(--muted); font-size: 12.5px; white-space: normal; min-width: 70px; vertical-align: bottom; }
table.t th:first-child, table.t td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; }
table.t th:first-child { z-index: 3; }
table.t td.l, table.t th.l { text-align: left; }
table.t tr.total td { font-weight: 700; background: var(--bg2); }
table.t td.edit { cursor: pointer; color: var(--blue); }
table.t td.edit:hover { background: var(--bg2); }
table.t td.hl { font-weight: 700; }
table.t tr.group td { background: var(--bg2); font-weight: 700; text-align: left; }

/* табель */
table.ts td, table.ts th { padding: 0; min-width: 30px; text-align: center; }
table.ts th { padding: 6px 2px; font-size: 11px; }
table.ts td:first-child, table.ts th:first-child { padding: 6px 10px; min-width: 150px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
table.ts td.c { cursor: pointer; height: 34px; font-weight: 700; font-size: 13px; user-select: none; }
table.ts td.c:hover { outline: 2px solid var(--line); outline-offset: -2px; }
table.ts .we { background: var(--bg2); }
table.ts .m-р { color: var(--ok); }
table.ts .m-в { color: var(--blue); }
table.ts .m-л { color: var(--warn); }
table.ts .m-п { color: var(--muted); }
table.ts .m-н { color: var(--bad); }
table.ts .scan-dot { color: var(--accent); }
table.ts .td-today { box-shadow: inset 0 0 0 2px var(--accent); }

/* ------------------------------------------------------ нижня панель --- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--line2);
}
.nav button { flex: 1; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); padding: 6px 0; }
.nav button .i { font-size: 23px; line-height: 1; filter: grayscale(1); opacity: 0.75; }
.nav button.on { color: var(--text); font-weight: 700; }
.nav button.on .i { filter: none; opacity: 1; }
.nav button.scan .i {
  width: 46px; height: 46px; border-radius: 15px; background: var(--grad); display: flex; align-items: center; justify-content: center;
  filter: none; opacity: 1; font-size: 22px; margin-top: -6px; box-shadow: 0 6px 16px -6px rgba(225, 48, 108, 0.7);
}

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 230px; }
  .nav {
    top: 0; right: auto; width: 230px; height: 100vh; flex-direction: column; justify-content: flex-start; align-items: stretch;
    border-top: 0; border-right: 1px solid var(--line2); padding: 76px 10px 10px; gap: 4px;
  }
  .nav::before { content: 'Глобал Імідж'; position: absolute; top: 20px; left: 22px; font-family: 'Brush Script MT', 'Segoe Script', cursive; font-size: 27px; color: var(--text); }
  .nav button { flex: 0 0 auto; flex-direction: row; gap: 14px; font-size: 15px; padding: 12px 14px; border-radius: 10px; color: var(--text); }
  .nav button:hover { background: var(--bg2); }
  .nav button.scan .i { width: 30px; height: 30px; border-radius: 9px; margin: 0; font-size: 16px; }
  .top .logo { visibility: hidden; }
}

/* ------------------------------------------------- модалки і тости --- */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); animation: up 0.2s ease-out;
}
.sheet::before { content: ''; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 2px auto 12px; }
.sheet h2 { margin: 0 0 12px; font-size: 18px; text-align: center; }
@media (min-width: 700px) {
  .sheet-back { align-items: center; }
  .sheet { border-radius: 18px; }
  .sheet::before { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: #262626; color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); animation: up 0.2s;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.ticket-card { border-radius: 16px; padding: 16px; background: var(--grad-soft); margin-bottom: 14px; }
.ticket-card .op { font-size: 20px; font-weight: 800; margin: 4px 0; }
.ticket-card .meta { color: var(--muted); font-size: 14px; }
.ticket-card .sum { font-size: 30px; font-weight: 800; margin-top: 8px; }

.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty .e { font-size: 44px; margin-bottom: 8px; }
.loading { text-align: center; padding: 40px; color: var(--muted); }
.op-row { display: grid; grid-template-columns: 1fr 86px 70px 34px; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line2); }
.op-row .input { min-height: 36px; padding: 6px 8px; }
.op-row.head { font-size: 12px; color: var(--muted); border: 0; padding-bottom: 0; }
.x-btn { border: 0; background: none; cursor: pointer; font-size: 17px; color: var(--muted); }
