/* ==========================================================================
   Satış Takip — iOS / iPadOS design language
   tokens → base → controls → shell → screens → lists → overlays → lock → responsive
   ========================================================================== */

/* ---------- Tokens: light ---------- */
:root {
  color-scheme: light;

  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-elevated: #ffffff;
  --material: rgba(249, 249, 251, 0.8);
  --material-alert: rgba(242, 242, 244, 0.92);
  --sidebar-bg: #f2f2f7;

  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.72);
  --label-3: rgba(60, 60, 67, 0.45);
  --label-inverse: #ffffff;

  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.07);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --seg-active: #ffffff;
  --input-bg: #ffffff;
  --input-border: rgba(60, 60, 67, 0.18);
  --separator: rgba(60, 60, 67, 0.14);
  --separator-strong: rgba(60, 60, 67, 0.24);

  --sys-blue: #007aff;
  --sys-green: #34c759;
  --sys-orange: #ff9500;
  --sys-red: #ff3b30;
  --sys-purple: #af52de;
  --sys-pink: #ff2d55;
  --sys-teal: #30b0c7;
  --sys-indigo: #5856d6;
  --sys-gray: #8e8e93;

  --accent: #007aff;
  --accent-hover: #0a84ff;
  --accent-text: #0064d6;
  --green: #248a3d;
  --orange: #c45500;
  --red: #d70015;
  --purple: #8944ab;
  --cyan: #0071a4;
  --indigo: #3634a3;
  --pink: #d30f45;
  --teal: #0b7285;

  --tint-blue: rgba(0, 122, 255, 0.12);
  --tint-green: rgba(52, 199, 89, 0.15);
  --tint-orange: rgba(255, 149, 0, 0.16);
  --tint-red: rgba(255, 59, 48, 0.12);
  --tint-purple: rgba(175, 82, 222, 0.13);
  --tint-pink: rgba(255, 45, 85, 0.12);
  --tint-teal: rgba(48, 176, 199, 0.15);
  --tint-indigo: rgba(88, 86, 214, 0.13);

  --focus-ring: 0 0 0 4px rgba(0, 122, 255, 0.3);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-widget: 0 2px 12px rgba(0, 0, 0, 0.05), 0 0 0 0.5px rgba(0, 0, 0, 0.03);
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-modal: 0 30px 80px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-widget: 22px;
  --r-pill: 999px;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --dur-fast: 150ms;
  --dur: 240ms;
  --dur-slow: 400ms;

  --sidebar-w: 288px;
  --tabbar-h: 54px;

  --z-tabbar: 40;
  --z-modal: 100;
  --z-alert: 200;
  --z-toast: 300;
}

/* ---------- Tokens: dark ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-elevated: #1c1c1e;
  --material: rgba(22, 22, 24, 0.78);
  --material-alert: rgba(44, 44, 46, 0.92);
  --sidebar-bg: #0d0d0f;

  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.66);
  --label-3: rgba(235, 235, 245, 0.36);
  --label-inverse: #000000;

  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.14);
  --fill-strong: rgba(120, 120, 128, 0.36);
  --seg-active: #636366;
  --input-bg: rgba(118, 118, 128, 0.18);
  --input-border: rgba(255, 255, 255, 0.08);
  --separator: rgba(84, 84, 88, 0.55);
  --separator-strong: rgba(84, 84, 88, 0.8);

  --sys-blue: #0a84ff;
  --sys-green: #30d158;
  --sys-orange: #ff9f0a;
  --sys-red: #ff453a;
  --sys-purple: #bf5af2;
  --sys-pink: #ff375f;
  --sys-teal: #40c8e0;
  --sys-indigo: #5e5ce6;

  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-text: #409cff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;
  --cyan: #64d2ff;
  --indigo: #7d7aff;
  --pink: #ff375f;
  --teal: #40c8e0;

  --tint-blue: rgba(10, 132, 255, 0.2);
  --tint-green: rgba(48, 209, 88, 0.18);
  --tint-orange: rgba(255, 159, 10, 0.18);
  --tint-red: rgba(255, 69, 58, 0.18);
  --tint-purple: rgba(191, 90, 242, 0.2);
  --tint-pink: rgba(255, 55, 95, 0.18);
  --tint-teal: rgba(64, 200, 224, 0.18);
  --tint-indigo: rgba(94, 92, 230, 0.22);

  --focus-ring: 0 0 0 4px rgba(10, 132, 255, 0.45);
  --shadow-card: none;
  --shadow-widget: none;
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --shadow-modal: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.is-booting #loginView,
body.is-booting .app-shell { visibility: hidden; }

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -0.022em; }
p, dl, dd { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
strong { font-weight: 600; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--tint-blue); }

* { scrollbar-width: thin; scrollbar-color: var(--fill-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fill-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon,
button svg, a svg, .toast-icon svg {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: var(--z-toast);
  padding: 8px 14px; border-radius: var(--r-sm);
  background: var(--accent); color: #fff; font-weight: 600;
  transform: translateY(-160%); transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: none; }

/* utilities */
.mono { font-variant-numeric: tabular-nums; }
.text-primary, .text-strong { color: var(--label); }
.text-strong, .fw-600 { font-weight: 600; }
.text-secondary, .text-muted { color: var(--label-2); }
.text-tertiary { color: var(--label-3) !important; }
.text-accent { color: var(--accent-text) !important; }
.text-emerald { color: var(--green) !important; }
.text-gold { color: var(--orange) !important; }
.text-red { color: var(--red) !important; }
.text-purple { color: var(--purple) !important; }
.text-cyan { color: var(--cyan) !important; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.flex-1 { flex: 1 1 0; min-width: 0; }
.flex-2 { flex: 2 1 0; min-width: 0; }
.mt-1 { margin-top: 4px; }
.ta-right { text-align: right; }

/* iOS Settings color tiles and tints */
.tile-blue { --tile: var(--sys-blue); }
.tile-green { --tile: var(--sys-green); }
.tile-orange { --tile: var(--sys-orange); }
.tile-red { --tile: var(--sys-red); }
.tile-purple { --tile: var(--sys-purple); }
.tile-pink { --tile: var(--sys-pink); }
.tile-teal { --tile: var(--sys-teal); }
.tile-indigo { --tile: var(--sys-indigo); }
.tile-gray { --tile: var(--sys-gray); }

.tint-blue { background: var(--tint-blue); color: var(--accent-text); }
.tint-green { background: var(--tint-green); color: var(--green); }
.tint-orange { background: var(--tint-orange); color: var(--orange); }
.tint-red { background: var(--tint-red); color: var(--red); }
.tint-purple { background: var(--tint-purple); color: var(--purple); }
.tint-pink { background: var(--tint-pink); color: var(--pink); }
.tint-teal { background: var(--tint-teal); color: var(--teal); }
.tint-indigo { background: var(--tint-indigo); color: var(--indigo); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 16px;
  border: 0; border-radius: var(--r-pill);
  background: var(--fill); color: var(--label);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background-color var(--dur-fast) ease, opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn .icon { width: 16px; height: 16px; stroke-width: 2.2; margin-left: -3px; }

.btn-filled, .btn-primary { background: var(--accent); color: #fff; }
.btn-filled:hover, .btn-primary:hover { background: var(--accent-hover); }
.btn-tinted { background: var(--tint-blue); color: var(--accent-text); }
.btn-tinted:hover { background: rgba(0, 122, 255, 0.18); }
.btn-gray, .btn-secondary { background: var(--fill); color: var(--label); }
.btn-gray:hover, .btn-secondary:hover { background: var(--fill-strong); }
.btn-green, .btn-success { background: var(--tint-green); color: var(--green); }
.btn-plain { background: transparent; color: var(--accent-text); }
.btn-plain:hover { background: var(--fill-2); }

.btn-sm { height: 30px; padding: 0 13px; font-size: 13.5px; }
.btn-xs { height: 28px; padding: 0 12px; font-size: 13px; }
.btn-large { height: 48px; border-radius: 14px; font-size: 16px; width: 100%; }
.btn-icon-only { width: 34px; padding: 0; }
.btn-icon-glyph { display: inline-grid; place-items: center; }
.btn-icon-glyph svg { width: 16px; height: 16px; stroke-width: 2.2; }

.btn-danger-xs {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--label-3);
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.btn-danger-xs svg { width: 17px; height: 17px; }
.btn-danger-xs:hover { background: var(--tint-red); color: var(--red); }

.icon-btn, .mini-icon-btn {
  display: inline-grid; place-items: center; flex: none;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--label-2);
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}
.icon-btn { width: 34px; height: 34px; }
.icon-btn .icon { width: 19px; height: 19px; }
.mini-icon-btn { width: 26px; height: 26px; }
.mini-icon-btn .icon { width: 14px; height: 14px; transition: transform 600ms var(--ease); }
.mini-icon-btn.is-spinning .icon { transform: rotate(360deg); }
.icon-btn:hover, .mini-icon-btn:hover { background: var(--fill); color: var(--label); }
.icon-btn:active { transform: scale(0.92); }

.link-btn {
  display: inline-flex; align-items: center; gap: 2px;
  border: 0; background: none; padding: 4px 0;
  color: var(--accent-text); font-size: 15px; font-weight: 400;
  cursor: pointer;
}
.link-btn .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.link-btn:hover { opacity: 0.7; }

:root[data-theme="dark"] .theme-icon-moon,
:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-label-light,
:root[data-theme="light"] .theme-label-dark { display: none; }

/* ---------- Pills & badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: var(--r-pill);
  background: var(--fill); color: var(--label-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill.paid, .pill.settled { background: var(--tint-green); color: var(--green); }
.pill.pending { background: var(--tint-orange); color: var(--orange); }
.pill.debt { background: var(--tint-red); color: var(--red); }
.pill.site-bal { background: var(--tint-purple); color: var(--purple); }
.pill.paid::before, .pill.pending::before, .pill.debt::before, .pill.site-bal::before, .pill.settled::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: var(--r-pill); background: var(--fill); color: var(--label-2);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0; text-transform: none; vertical-align: middle;
}
.badge.emerald { background: var(--tint-green); color: var(--green); }
.count-chip {
  display: inline-flex; align-items: center; height: 20px; margin-left: 8px; padding: 0 8px;
  border-radius: var(--r-pill); background: var(--fill); color: var(--label-2);
  font-family: var(--font-sans); font-size: 12px; font-weight: 500; letter-spacing: 0; vertical-align: 3px;
}

/* ---------- Form controls ---------- */
.form-control {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--input-border); border-radius: 10px;
  background: var(--input-bg); color: var(--label); font-size: 16px;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.form-control::placeholder { color: var(--label-3); }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
textarea.form-control { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
select.form-control, .select-plain {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 9.5l4-4 4 4M8 14.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px;
}
select.form-control { padding-right: 34px; background-position: right 10px center; }
.select-plain {
  height: 32px; padding: 0 22px 0 8px; border: 0; border-radius: var(--r-sm);
  background-color: transparent; background-position: right 2px center;
  color: var(--label-2); font-size: 15px; text-align: right;
}
.select-plain:hover { color: var(--label); }
.form-control-sm { height: 32px; font-size: 14px; border-radius: 9px; }
.form-control-sm.select-plain { border: 0; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.form-group label, .field label { color: var(--label-2); font-size: 13px; font-weight: 500; padding-left: 2px; }
.modal-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.setting-hint { display: block; color: var(--label-3); font-size: 12.5px; }
.currency-input-row { display: flex; gap: 8px; }
.form-control-currency { width: 116px; flex: none; }
.qty-stepper-wrap { display: flex; align-items: center; gap: 6px; }
.qty-stepper-wrap .form-control { flex: 1; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.qty-stepper-wrap .btn { height: 32px; padding: 0 10px; }
.input-with-action { display: block; }
.inline-add-form { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.inline-add-form .form-group { margin-bottom: 0; }
.inline-add-form .btn { height: 40px; }
.alert-box-info {
  margin-bottom: 14px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--tint-blue); color: var(--label-2); font-size: 13.5px; line-height: 1.45;
}
.alert-box-info strong { color: var(--label); }

/* iOS switch */
.toggle-switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.toggle-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.slider { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--fill-strong); transition: background-color var(--dur) var(--ease); }
.slider::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06);
  transition: transform var(--dur) var(--ease);
}
.toggle-switch input:checked + .slider { background: var(--sys-green); }
.toggle-switch input:checked + .slider::before { transform: translateX(20px); }
.toggle-switch input:focus-visible + .slider { box-shadow: var(--focus-ring); }

/* segmented control */
.segmented {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px; border-radius: 10px; background: var(--fill);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 14px; flex: 1 0 auto;
  border: 0; border-radius: 8px; background: transparent; color: var(--label);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.segmented button.active {
  background: var(--seg-active);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}
.seg-count { color: var(--label-2); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.segmented-sm { margin-top: 8px; }
.segmented-sm button { height: 26px; padding: 0 10px; font-size: 13px; }
.segmented-sm button:hover { background: var(--seg-active); }

/* search bar */
.search-field {
  display: flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 10px; margin-bottom: 18px;
  border-radius: 11px; background: var(--fill);
  color: var(--label-2);
  transition: box-shadow var(--dur-fast) ease;
}
.search-field:focus-within { box-shadow: var(--focus-ring); }
.search-field .icon { width: 17px; height: 17px; }
.search-field input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: none; background: transparent;
  color: var(--label); font-size: 16px;
}
.search-field input::placeholder { color: var(--label-2); }
.search-field-inline { margin-bottom: 0; flex: 0 1 320px; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0;
  display: flex; flex-direction: column; gap: 14px;
  height: 100dvh; padding: 20px 14px 14px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--separator);
  overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 4px 8px 6px; }
.brand-icon {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: linear-gradient(180deg, #4aa3ff 0%, #0064e0 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.brand-icon svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }

.sidebar-section {
  margin: 10px 10px 6px;
  color: var(--label-2); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; text-transform: uppercase;
}
.sidebar .nav-tabs { display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav-tab {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 44px; padding: 0 10px;
  border: 0; border-radius: 11px;
  background: transparent; color: var(--label);
  font-size: 16px; font-weight: 400; text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease;
}
.sidebar .nav-tab:hover { background: var(--fill-2); }
.sidebar .nav-tab.active { background: var(--accent); color: #fff; }
.tile {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 7px; background: var(--tile, var(--sys-gray)); color: #fff;
}
.tile .icon { width: 18px; height: 18px; stroke-width: 2; }
.tab-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-badge {
  min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: var(--r-pill); color: var(--label-2);
  font-size: 13px; font-weight: 500; line-height: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar .nav-tab.active .tab-badge { color: rgba(255, 255, 255, 0.85); }

.sidebar-widget {
  margin-top: auto;
  padding: 4px 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.sw-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 40px; font-size: 14px;
  border-bottom: 1px solid var(--separator);
  font-variant-numeric: tabular-nums;
}
.sw-row:last-child { border-bottom: 0; }
.sw-label { color: var(--label-2); }
.sw-value { display: inline-flex; align-items: center; gap: 4px; }

.sidebar-footer { display: flex; align-items: center; gap: 4px; padding: 4px 4px 0 6px; }
.admin-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 50%; background: linear-gradient(180deg, #a1a1a6, #7c7c80); color: #fff;
}
.admin-avatar .icon { width: 18px; height: 18px; }
.sidebar-user { flex: 1; min-width: 0; margin-left: 6px; font-size: 15px; font-weight: 500; }

.app-main { min-width: 0; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 40px 96px; outline: none; }

.tab-bar { display: none; }

/* ---------- Page header (Large Title) ---------- */
.tab-content { display: none; }
.tab-content.active { display: block; animation: rise var(--dur-slow) var(--ease) both; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 12px 20px; margin-bottom: 22px;
}
.page-eyebrow {
  margin-bottom: 2px;
  color: var(--label-2); font-size: 13px; font-weight: 600;
  letter-spacing: 0.01em; text-transform: uppercase;
}
.large-title { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.date-range { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--label-3); }
.date-range .form-control { width: auto; }

/* ---------- Kasa: Wallet card + actions ---------- */
.wallet-row { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }

.wallet-card {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 250px; padding: 22px 24px 20px;
  border-radius: 24px;
  color: #fff;
  overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(48, 209, 88, 0.55) 0%, transparent 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(10, 132, 255, 0.5) 0%, transparent 60%),
    linear-gradient(160deg, #1d2a24 0%, #101418 60%, #0b0d12 100%);
  box-shadow: 0 18px 40px rgba(16, 40, 30, 0.28), inset 0 0 0 0.5px rgba(255, 255, 255, 0.12);
}
.wallet-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 38%);
}
.wallet-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wallet-top { display: flex; align-items: center; justify-content: space-between; }
.wallet-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.wallet-brand .icon { width: 20px; height: 20px; }
.wallet-chip {
  padding: 3px 10px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16); font-size: 12px; font-weight: 600;
}
.wallet-balance { display: flex; flex-direction: column; margin: auto 0 18px; padding-top: 26px; }
.wallet-amount {
  font-family: var(--font-rounded); font-size: 50px; font-weight: 700;
  letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums;
}
.wallet-usd { margin-top: 6px; color: rgba(255, 255, 255, 0.7); font-size: 15px; font-variant-numeric: tabular-nums; }
.wallet-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.wallet-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wallet-stat-label { color: rgba(255, 255, 255, 0.68); font-size: 12px; font-weight: 500; }
.wallet-stat strong { font-size: 18px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet-stat-sub { color: rgba(255, 255, 255, 0.55); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.action-circles {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  padding: 18px; border-radius: 24px;
  background: var(--surface); box-shadow: var(--shadow-widget);
}
.action-circle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 6px; border: 0; border-radius: 18px;
  background: transparent; cursor: pointer;
  transition: background-color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}
.action-circle:hover { background: var(--fill-2); }
.action-circle:active { transform: scale(0.95); }
.ac-icon {
  display: grid; place-items: center; width: 54px; height: 54px;
  border-radius: 50%; background: var(--tile); color: #fff;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--tile) 35%, transparent);
}
.ac-icon .icon { width: 24px; height: 24px; stroke-width: 2; }
.ac-label { font-size: 13px; font-weight: 500; color: var(--label); }

/* widgets */
.widget-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 32px; }
.widget {
  padding: 18px 20px 14px;
  border-radius: var(--r-widget);
  background: var(--surface);
  box-shadow: var(--shadow-widget);
  min-width: 0;
}
.widget-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.widget-title { font-size: 19px; font-weight: 700; letter-spacing: -0.022em; }
.widget-caption { margin-top: 2px; color: var(--label-2); font-size: 13px; }
.widget-total { font-family: var(--font-rounded); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }

.partner-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; margin-top: 6px; }
.partner-card { padding: 14px; border-radius: 16px; background: var(--surface-2); }
.partner-card-header { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.partner-card > .btn { width: 100%; margin-top: 12px; }
.partner-avatar {
  display: grid; place-items: center; width: 42px; height: 42px;
  border-radius: 50%; background: var(--avatar-color, var(--sys-indigo)); color: #fff;
  font-family: var(--font-rounded); font-size: 18px; font-weight: 700;
}
.partner-info { min-width: 0; }
.partner-name { font-size: 16px; font-weight: 600; }
.partner-net { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv-list { margin-top: 12px; }
.kv-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 0; margin-top: 8px; border-top: 1px solid var(--separator); font-size: 13.5px; }
.kv-list dt { color: var(--label-2); }
.kv-list dd { font-weight: 600; font-variant-numeric: tabular-nums; }

/* calculator */
.calc-widget { margin-bottom: 8px; padding-bottom: 20px; }
.rate-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 4px 0 12px; border-radius: var(--r-pill);
  background: var(--fill-2); color: var(--label-2); font-size: 13px; white-space: nowrap;
}
.rate-chip strong { color: var(--label); font-variant-numeric: tabular-nums; }
.calc-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; margin-top: 14px; }
.calc-fields { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; }
.field-swap { padding-bottom: 10px; color: var(--label-3); }
.field-swap .icon { width: 20px; height: 20px; }
.field .form-control { font-variant-numeric: tabular-nums; }
.calc-result { display: flex; flex-direction: column; padding: 18px; border-radius: 18px; background: var(--surface-2); }
.calc-result-label { color: var(--label-2); font-size: 13px; font-weight: 500; }
.calc-result-value { margin-top: 4px; font-family: var(--font-rounded); font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--green); }
.calc-result-sub { color: var(--label-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.calc-result-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; padding-top: 14px; border-top: 1px solid var(--separator); }
.calc-result-split span { display: block; color: var(--label-2); font-size: 12px; }
.calc-result-split strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.calc-result-split small { display: block; color: var(--label-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.calc-result .btn-large { margin-top: auto; }

/* ---------- Lists (inset grouped) ---------- */
.lists-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 24px; margin-bottom: 32px; }
.lists-grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.list-section { margin-bottom: 30px; min-width: 0; }
.lists-grid .list-section { margin-bottom: 0; }
.list-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 4px 10px; }
.list-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.024em; }

.list, .list-inset {
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.list-plain { background: transparent; box-shadow: none; border-radius: 0; margin: 0 -20px; }
.list-plain .row { padding-left: 20px; padding-right: 20px; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 14px;
  min-height: 60px;
  padding: 11px 16px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background-color var(--dur-fast) ease;
}
.row::after {
  content: ""; position: absolute; left: 68px; right: 0; bottom: 0;
  height: 1px; background: var(--separator);
  transform: scaleY(0.6); transform-origin: bottom;
}
.list > .row:last-child::after,
.list-inset > .row:last-child::after { display: none; }
.row:hover { background: var(--fill-2); }
.row.is-disabled > :not(.toggle-switch):not(.btn-danger-xs) { opacity: 0.45; }

.row-rich { grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: start; }
.row-rich > .row-icon { margin-top: 2px; }
.row-rich > .row-trail { padding-top: 2px; }
.row-rich > .row-actions { align-self: center; }

.row-icon {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0;
}
.row-icon .icon { width: 20px; height: 20px; }
.row-icon.avatar { border-radius: 50%; font-family: var(--font-rounded); font-size: 16px; }
.row-icon[class*="tile-"] { width: 30px; height: 30px; border-radius: 7px; background: var(--tile); color: #fff; margin: 0 4px; }
.row-icon[class*="tile-"] .icon { width: 18px; height: 18px; stroke-width: 2; }

.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-size: 16px; font-weight: 500; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub {
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 5px;
  color: var(--label-2); font-size: 13px; font-variant-numeric: tabular-nums;
}
.row-main > .pill { align-self: flex-start; margin-top: 6px; }
.dot-sep { color: var(--label-3); }
.row-url { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.row-note { margin-top: 5px; color: var(--label-3); font-size: 12.5px; line-height: 1.35; }
.row-trail { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.row-trail .row-sub { justify-content: flex-end; }
.row-amount { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-trail .row-note { margin: 0; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-value { color: var(--label-2); font-size: 15px; }
.row-chevron { width: 15px; height: 15px; color: var(--label-3); stroke-width: 2.2; }

.row-button { cursor: pointer; font: inherit; grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
/* quick lists: let long titles use two lines instead of a hard cut */
.lists-grid .row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-button .row-title { white-space: normal; }
.row-buttons { display: flex; justify-content: flex-end; gap: 8px; min-height: 54px; }

.row-field { grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.4fr); min-height: 50px; }
.row-field::after { left: 16px; }
.row-label { font-size: 16px; }
.row-input {
  width: 100%; height: 34px; padding: 0 4px;
  border: 0; border-radius: 8px; outline: none;
  background: transparent; color: var(--label); font-size: 16px; text-align: right;
}
.row-input::placeholder { color: var(--label-3); }
.row-input:focus { background: var(--fill-2); }

.list-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 36px 16px; color: var(--label-3); font-size: 14px; text-align: center;
}
.list-empty .icon { width: 30px; height: 30px; stroke-width: 1.5; }
.list-plain .list-empty { padding: 24px 16px; }

.list-day {
  padding: 16px 16px 6px;
  background: var(--surface);
  color: var(--label-2); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; text-transform: uppercase;
  border-bottom: 1px solid var(--separator);
}
.list-day:not(:first-child) { border-top: 8px solid var(--bg); }

/* ---------- Stat tiles / callouts ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-tile {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 16px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow-widget); min-width: 0;
}
.stat-label { color: var(--label-2); font-size: 13px; font-weight: 500; }
.stat-value { font-family: var(--font-rounded); font-size: 24px; font-weight: 700; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-tiles-lg .stat-value { font-size: 28px; }
.stat-hint { color: var(--label-3); font-size: 12px; }

.callout { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding: 14px 16px; border-radius: 16px; }
.callout-orange { background: var(--tint-orange); }
.callout-icon { color: var(--orange); padding-top: 1px; }
.callout-icon .icon { width: 22px; height: 22px; }
.callout h4 { font-size: 16px; font-weight: 600; }
.callout p { margin-top: 2px; color: var(--label-2); font-size: 13.5px; }

/* monthly cards */
.month-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.month-cards > .list-empty { grid-column: 1 / -1; border-radius: 14px; background: var(--surface); }
.month-card { padding: 16px 18px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-widget); }
.month-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.month-card-head h3 { font-size: 18px; font-weight: 700; }
.month-card-head strong { font-family: var(--font-rounded); font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 9px; }
.bar-label { color: var(--label-2); font-size: 12.5px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.bar-fill { display: block; width: var(--w, 0%); height: 100%; border-radius: 4px; animation: grow 700ms var(--ease) both; transform-origin: left; }
.fill-green { background: var(--sys-green); }
.fill-red { background: var(--sys-red); }
.fill-orange { background: var(--sys-orange); }
.bar-value { min-width: 92px; font-size: 12.5px; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Store bot ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-widget);
  color: var(--label-2); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sys-green); flex: none; }
.status-dot.pulsing { animation: dot-pulse 2s ease-in-out infinite; }
.status-pill.paused .status-dot { background: var(--sys-orange); animation: none; }
.icon-spin-hidden { display: none; }
.icon-spin { display: inline-block; width: 16px; height: 16px; animation: spin 0.8s linear infinite; }

.scan-status { margin-bottom: 20px; padding: 14px 16px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-widget); }
.scan-status-text { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--label-2); font-size: 13.5px; }
.scan-status-text strong { color: var(--label); font-variant-numeric: tabular-nums; }
.progress-bar-container { height: 5px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.progress-bar-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 1s linear; }

.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 16px; margin-bottom: 32px; }
.grid-cards { display: contents; }
.store-card {
  display: flex; flex-direction: column;
  padding: 18px 20px 14px; border-radius: var(--r-widget);
  background: var(--surface); box-shadow: var(--shadow-widget);
}
.store-card.is-disabled { opacity: 0.55; }
.store-card-head { display: flex; align-items: center; gap: 12px; }
.store-card-name { flex: 1; min-width: 0; }
.store-title { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-badge { color: var(--label-2); font-size: 12.5px; }
.store-link {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 50%; background: var(--fill-2); color: var(--accent-text);
}
.store-link:hover { background: var(--fill); }
.store-link svg { width: 16px; height: 16px; }
.sales-number-container { display: flex; align-items: baseline; gap: 6px; margin: 18px 0 14px; }
.sales-number { font-family: var(--font-rounded); font-size: 54px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.sales-unit { color: var(--label-2); font-size: 16px; }
.store-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.store-stats > div { padding: 8px 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.store-stats dt { color: var(--label-2); font-size: 11.5px; }
.store-stats dd { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin-top: 10px; color: var(--label-3); font-size: 12.5px; }
.store-card.sale-pulse { animation: sale-pulse 1.4s var(--ease-out); }

.add-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 236px; border: 1.5px dashed var(--separator-strong); border-radius: var(--r-widget);
  background: transparent; color: var(--accent-text); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.add-tile .icon { width: 30px; height: 30px; stroke-width: 1.8; }
.add-tile:hover { background: var(--tint-blue); border-color: transparent; }

.live-dot-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--tint-green); color: var(--green); font-size: 12px; font-weight: 600;
}
.live-dot-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: dot-pulse 2s ease-in-out infinite; }
.logs-console {
  height: 360px; overflow: auto; padding: 12px 14px;
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
}
.log-line { color: var(--label-2); white-space: pre-wrap; word-break: break-word; }
.log-line.warn { color: var(--orange); }
.log-line.error { color: var(--red); }
.log-line.sale { color: var(--green); font-weight: 600; }
.lists-grid-2 .list { max-height: 360px; overflow-y: auto; }

/* ---------- Settings (iOS Settings app) ---------- */
.settings-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 32px; align-items: start; }
.settings-group { margin-bottom: 30px; }
.group-title {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px 7px;
  color: var(--label-2); font-family: var(--font-sans); font-size: 13px; font-weight: 400;
  letter-spacing: 0.01em; text-transform: uppercase;
}
.group-footer { padding: 7px 16px 0; color: var(--label-2); font-size: 13px; line-height: 1.4; }
.settings-group .row { min-height: 52px; padding-top: 8px; padding-bottom: 8px; }
.settings-group .row::after { left: 62px; }
.settings-group .row-field::after { left: 16px; }
.settings-group .row-buttons::after { display: none; }
.settings-group .row .row-sub { font-size: 12.5px; }
#targetLinksContainer .row { grid-template-columns: auto minmax(0, 1fr) auto auto; }
#targetLinksContainer .list-empty { padding: 22px 16px; }

/* ---------- Modals (iOS sheet) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur) ease, visibility 0s linear var(--dur);
}
.modal-backdrop.active { opacity: 1; visibility: visible; transition: opacity var(--dur) ease; }
.modal-card {
  display: flex; flex-direction: column;
  width: min(540px, 100%); max-height: calc(100dvh - 48px);
  border-radius: 22px;
  background: var(--bg);
  box-shadow: var(--shadow-modal);
  transform: translateY(16px) scale(0.97);
  transition: transform var(--dur-slow) var(--ease);
}
:root[data-theme="dark"] .modal-card { background: #1c1c1e; }
.modal-backdrop.active .modal-card { transform: none; }
.modal-large { width: min(760px, 100%); }
.modal-card > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.modal-title { font-size: 20px; font-weight: 700; letter-spacing: -0.022em; }
.modal-close {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 50%; background: var(--fill); color: var(--label-2); cursor: pointer;
}
.modal-close:hover { background: var(--fill-strong); }
.modal-close .icon { width: 15px; height: 15px; stroke-width: 2.4; }
.modal-body { padding: 10px 20px 8px; overflow-y: auto; }
.modal-desc { margin-bottom: 16px; color: var(--label-2); font-size: 14px; }
.modal-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 20px 18px; }
.modal-footer .btn { min-width: 100px; height: 40px; }
.modal-card .form-control { background: var(--surface); }
:root[data-theme="dark"] .modal-card .form-control { background: var(--surface-2); border-color: transparent; }
.modal-list { margin-top: 14px; max-height: 340px; overflow-y: auto; }
:root[data-theme="dark"] .modal-card .list-inset { background: var(--surface-2); }
.more-list .row { min-height: 52px; }

.order-total-preview {
  display: flex; align-items: stretch; gap: 16px;
  margin: 2px 0 16px; padding: 14px 16px;
  border-radius: 14px; background: var(--surface);
}
:root[data-theme="dark"] .order-total-preview { background: var(--surface-2); }
.preview-col { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.preview-label { color: var(--label-2); font-size: 12px; }
.preview-val { font-family: var(--font-rounded); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.preview-rate { color: var(--label-2); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.preview-divider { width: 1px; background: var(--separator); }

/* alert (appConfirm) */
.alert-backdrop {
  position: fixed; inset: 0; z-index: var(--z-alert);
  display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, 0.3); animation: fade-in var(--dur) ease both;
}
.alert-backdrop.leaving { animation: fade-out 180ms ease both; }
.alert-sheet {
  width: min(280px, 100%); border-radius: 14px; overflow: hidden; text-align: center;
  background: var(--material-alert);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--shadow-pop);
  animation: alert-in 320ms var(--ease) both;
}
.alert-content { padding: 20px 16px 16px; }
.alert-title { font-size: 17px; font-weight: 600; }
.alert-message { margin-top: 4px; font-size: 13px; line-height: 1.4; }
.alert-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--separator-strong); }
.alert-btn { height: 44px; border: 0; background: transparent; color: var(--accent-text); font-size: 17px; cursor: pointer; }
.alert-btn + .alert-btn { border-left: 1px solid var(--separator-strong); }
.alert-btn:hover { background: var(--fill-2); }
.alert-btn.primary, .alert-btn.destructive { font-weight: 600; }
.alert-btn.destructive { color: var(--red); }
.alert-btn:focus-visible { box-shadow: inset 0 0 0 3px rgba(0, 122, 255, 0.35); }

/* toast (notification banner) */
.toast-container {
  position: fixed; top: 12px; left: 50%; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 8px;
  width: min(380px, calc(100vw - 24px)); transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 22px;
  background: var(--material-alert);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--shadow-pop); pointer-events: auto;
  animation: toast-in 450ms var(--ease) both;
}
.toast.leaving { animation: toast-out 260ms ease both; }
.toast-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--sys-blue); color: #fff; }
.toast-icon svg { width: 19px; height: 19px; stroke-width: 2; }
.toast.sale .toast-icon { background: var(--sys-green); }
.toast.error .toast-icon { background: var(--sys-red); }
.toast-body { min-width: 0; }
.toast-title { font-size: 14px; font-weight: 600; }
.toast-message { color: var(--label-2); font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }

/* ---------- Lock screen (login) ---------- */
.login-view-wrapper {
  position: relative;
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center;
  min-height: 100dvh; padding: max(40px, env(safe-area-inset-top)) 20px max(26px, env(safe-area-inset-bottom));
  overflow: hidden; isolation: isolate; color: #fff;
}
.lock-wallpaper {
  position: absolute; inset: 0; z-index: -1; overflow: hidden;
  background: linear-gradient(180deg, #2f5fd8 0%, #6a4fd8 52%, #e2677e 100%);
}
:root[data-theme="dark"] .lock-wallpaper { background: linear-gradient(180deg, #0a1a4a 0%, #24145a 55%, #4a1631 100%); }
.lock-wallpaper::after {
  content: ""; position: absolute; inset: 0; opacity: 0.07; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.75; animation: drift 22s ease-in-out infinite alternate; }
.blob-1 { width: 60vmax; height: 60vmax; left: -18vmax; top: -22vmax; background: #3fa2ff; }
.blob-2 { width: 50vmax; height: 50vmax; right: -16vmax; top: 18vh; background: #b45cff; animation-duration: 28s; }
.blob-3 { width: 55vmax; height: 55vmax; left: 10vw; bottom: -30vmax; background: #ff8a5c; animation-duration: 25s; }
:root[data-theme="dark"] .blob { opacity: 0.45; }

.lock-theme-btn {
  position: absolute; top: 16px; right: 16px;
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, 0.18); color: #fff;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.lock-theme-btn .icon { width: 20px; height: 20px; }

.lock-top { display: flex; flex-direction: column; align-items: center; text-align: center; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.12); }
.lock-glyph { width: 20px; height: 20px; margin-bottom: 10px; opacity: 0.9; stroke-width: 2.2; }
.lock-date { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; opacity: 0.92; text-transform: capitalize; }
.lock-time {
  font-family: var(--font-rounded); font-size: clamp(84px, 16vw, 120px); font-weight: 700;
  letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums;
}

.login-card {
  align-self: center;
  width: min(360px, 100%); padding: 26px 22px 20px;
  border-radius: 30px; text-align: center; color: var(--label);
  background: rgba(255, 255, 255, 0.58);
  -webkit-backdrop-filter: saturate(180%) blur(40px); backdrop-filter: saturate(180%) blur(40px);
  box-shadow: 0 20px 60px rgba(20, 20, 60, 0.25), inset 0 0 0 0.5px rgba(255, 255, 255, 0.5);
  animation: rise 600ms var(--ease) both;
}
:root[data-theme="dark"] .login-card { background: rgba(28, 28, 30, 0.55); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 0.5px rgba(255, 255, 255, 0.12); }
.login-card.shake { animation: shake 420ms var(--ease-out); }
.login-app-icon {
  display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 12px;
  border-radius: 15px; background: linear-gradient(180deg, #4aa3ff 0%, #0064e0 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 20px rgba(0, 60, 160, 0.35);
}
.login-app-icon svg { width: 34px; height: 34px; fill: none; stroke: #fff; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.login-title { font-size: 22px; font-weight: 700; }
.login-desc { margin: 4px auto 18px; color: var(--label-2); font-size: 14px; }
.login-form { text-align: left; }
.login-input-wrap { position: relative; }
.login-input {
  width: 100%; height: 50px; padding: 0 94px 0 16px;
  border: 0; border-radius: 15px;
  background: rgba(255, 255, 255, 0.75); color: #000; font-size: 17px; letter-spacing: 0;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
:root[data-theme="dark"] .login-input { background: rgba(118, 118, 128, 0.28); color: #fff; }
.login-input::placeholder { color: var(--label-3); }
.login-input:focus { outline: none; box-shadow: var(--focus-ring); }
.login-eye-btn, .login-submit-btn {
  position: absolute; top: 7px; display: grid; place-items: center;
  width: 36px; height: 36px; border: 0; border-radius: 50%; cursor: pointer;
  transition: background-color var(--dur-fast) ease, opacity var(--dur) ease, transform var(--dur-fast) var(--ease-out);
}
.login-eye-btn { right: 49px; background: transparent; color: var(--label-2); }
.login-eye-btn:hover { background: var(--fill); }
.login-eye-btn .icon { width: 19px; height: 19px; }
.login-eye-btn .eye-closed { display: none; }
.login-eye-btn.is-visible .eye-open { display: none; }
.login-eye-btn.is-visible .eye-closed { display: block; }
.login-submit-btn { right: 7px; background: var(--accent); color: #fff; }
.login-submit-btn:active { transform: scale(0.92); }
.login-submit-btn .icon { width: 19px; height: 19px; stroke-width: 2.4; }
.login-input:placeholder-shown ~ .login-submit-btn { opacity: 0.35; }
.login-submit-btn .spinner { display: none; }
.login-submit-btn.is-loading .submit-arrow { display: none; }
.login-submit-btn.is-loading .spinner { display: block; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.login-error-alert { margin-top: 10px; color: var(--red); font-size: 14px; font-weight: 500; text-align: center; }
.remember-checkbox-label {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px; color: var(--label-2); font-size: 13.5px; cursor: pointer; user-select: none;
}
.remember-checkbox-label input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.login-footer { display: flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, 0.78); font-size: 12.5px; }
.login-footer .icon { width: 13px; height: 13px; }

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes alert-in { from { opacity: 0; transform: scale(1.12); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-24px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-16px) scale(0.97); } }
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes sale-pulse { 0% { box-shadow: var(--shadow-widget), 0 0 0 0 rgba(52, 199, 89, 0.55); } 100% { box-shadow: var(--shadow-widget), 0 0 0 18px rgba(52, 199, 89, 0); } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  :root { --sidebar-w: 248px; }
  .container { padding: 24px 28px 96px; }
  .widget-grid { grid-template-columns: minmax(0, 1fr); }
  .calc-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .wallet-row { grid-template-columns: minmax(0, 1fr); }
  .action-circles { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 10px; }
  .settings-columns { grid-template-columns: minmax(0, 1fr); }
}

/* iPhone / small tablet: tab bar instead of sidebar */
@media (max-width: 820px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .container { padding: max(14px, env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }

  .tab-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--material);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--separator);
  }
  .tab-bar .nav-tab, .tab-more {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: transparent; color: var(--sys-gray);
    font-size: 10.5px; font-weight: 500; letter-spacing: 0; cursor: pointer;
  }
  .tab-bar .icon { width: 25px; height: 25px; stroke-width: 1.9; }
  .tab-bar .tab-title { flex: none; }
  .tab-bar .nav-tab.active, .tab-more.active { color: var(--accent); }
  .tab-bar .nav-tab.active .icon, .tab-more.active .icon { stroke-width: 2.3; }

  .large-title { font-size: 34px; }
  .page-header { margin-bottom: 16px; }
  .page-actions .btn { height: 32px; padding: 0 13px; font-size: 14px; }
  .toolbar-row { flex-direction: column; align-items: stretch; }
  .segmented { width: 100%; }
  .search-field-inline { flex: none; }
  .date-range .form-control { flex: 1 1 120px; }
}

@media (max-width: 600px) {
  .wallet-card { min-height: 220px; padding: 18px 18px 16px; border-radius: 22px; }
  .wallet-amount { font-size: 42px; }
  .wallet-stats { gap: 8px; }
  .wallet-stat strong { font-size: 15px; }
  .wallet-stat-sub { display: none; }
  .ac-icon { width: 50px; height: 50px; }
  .ac-label { font-size: 12px; }

  .widget { padding: 16px 16px 10px; }
  .list-plain { margin: 0 -16px; }
  .list-plain .row { padding-left: 16px; padding-right: 16px; }
  .field-pair { grid-template-columns: minmax(0, 1fr); }
  .field-swap { display: none; }

  .row-rich { grid-template-columns: auto minmax(0, 1fr) auto; }
  .row-rich > .row-actions { grid-column: 2 / -1; justify-content: flex-start; margin-top: 6px; }
  .row-rich > .row-actions .btn-danger-xs { margin-left: auto; }
  .row-field { grid-template-columns: minmax(96px, 0.7fr) minmax(0, 1.3fr); }

  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value, .stat-tiles-lg .stat-value { font-size: 20px; }
  .bar-value { min-width: 78px; }
  .scan-status-text { flex-direction: column; gap: 2px; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-card, .modal-large {
    width: 100%; max-height: calc(100dvh - 20px);
    border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
  }
  .modal-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .order-total-preview { flex-direction: column; gap: 10px; }
  .preview-divider { width: auto; height: 1px; }
  .modal-footer .btn { flex: 1; }

  .lock-time { font-size: 88px; }
  .login-card { border-radius: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .tab-bar, .toast, .alert-sheet, .login-card { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface-elevated); }
}
