:root {
  --bg: #070912;
  --bg2: #0d1124;
  --panel: rgba(22, 27, 52, 0.62);
  --panel-solid: #151a33;
  --panel-hi: rgba(40, 48, 90, 0.7);
  --border: rgba(140, 160, 255, 0.14);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c5cff;
  --accent2: #00d4ff;
  --pink: #ff4fa3;
  --green: #22d39a;
  --red: #ff5c7a;
  --yellow: #ffc94d;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --radius: 18px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef1fb;
  --bg2: #e3e8fa;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #ffffff;
  --panel-hi: rgba(255, 255, 255, 0.95);
  --border: rgba(80, 90, 160, 0.16);
  --text: #171a33;
  --muted: #5d6488;
  --shadow: 0 20px 40px -24px rgba(40, 50, 120, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 80% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(0, 212, 255, 0.16), transparent 60%), var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
#bg3d { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; opacity: 0.85; }
a { color: var(--accent2); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }

.app { position: relative; z-index: 1; display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
  background: var(--panel); backdrop-filter: blur(18px); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.brand-logo {
  width: 44px; height: 44px; flex: none; background: url(../icons/logo.svg) center / contain no-repeat;
  font-size: 0; color: transparent; filter: drop-shadow(0 8px 18px rgba(124, 92, 255, 0.45));
  animation: float 5s ease-in-out infinite;
}
.brand-name { font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: 0.16em; }
.brand-sub { font-size: 12px; color: var(--muted); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted);
  text-decoration: none; font-weight: 500; font-size: 14px; transition: all 0.2s; position: relative;
}
.nav a .ico { width: 24px; text-align: center; font-size: 17px; transition: transform 0.3s; }
.nav a:hover { background: var(--panel-hi); color: var(--text); }
.nav a:hover .ico { transform: scale(1.25) rotate(-8deg); }
.nav a.active { background: linear-gradient(135deg, rgba(124, 92, 255, 0.3), rgba(0, 212, 255, 0.15)); color: var(--text); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--grad); }
.nav .badge { margin-left: auto; background: var(--pink); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 700; }
.sidebar-foot { display: flex; gap: 8px; }

/* Main */
.main { min-width: 0; padding: 18px 28px 40px; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 28px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; white-space: nowrap; }
.menu-btn { display: none; }
.search { position: relative; }
.search input { width: 300px; }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 360px; max-height: 380px; overflow: auto; display: none;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 50; padding: 6px;
}
.search-results.open { display: block; }
.search-results .sr { padding: 9px 11px; border-radius: 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.search-results .sr:hover { background: var(--panel-hi); }
.search-results .sr small { color: var(--muted); display: block; }

.view { animation: viewIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(4deg); } }

/* Layout helpers */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.mt { margin-top: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  backdrop-filter: blur(16px); box-shadow: var(--shadow); position: relative; min-width: 0;
}
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 .spacer { flex: 1; }
[data-tilt] { transform-style: preserve-3d; transition: transform 0.25s ease, box-shadow 0.25s; will-change: transform; }
[data-tilt]:hover { box-shadow: 0 30px 60px -25px rgba(124, 92, 255, 0.55); }
[data-tilt] .glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, 0.18), transparent 55%);
}
[data-tilt]:hover .glare { opacity: 1; }

.kpi { overflow: hidden; }
.kpi .kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .kpi-value { font-size: 30px; font-weight: 800; margin: 6px 0 4px; transform: translateZ(30px); letter-spacing: -0.03em; }
.kpi .kpi-foot { font-size: 12px; color: var(--muted); }
.kpi .kpi-ico {
  position: absolute; right: 16px; top: 16px; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 22px; background: var(--grad); transform: translateZ(50px); box-shadow: 0 10px 25px -8px var(--accent);
}
.kpi.green .kpi-ico { background: linear-gradient(135deg, #22d39a, #00b8d4); box-shadow: 0 10px 25px -8px var(--green); }
.kpi.red .kpi-ico { background: linear-gradient(135deg, #ff5c7a, #ff9f43); box-shadow: 0 10px 25px -8px var(--red); }
.kpi.pink .kpi-ico { background: linear-gradient(135deg, #ff4fa3, #7c5cff); box-shadow: 0 10px 25px -8px var(--pink); }

/* Hero 3D */
.hero {
  position: relative; height: 340px; border-radius: 24px; overflow: hidden; border: 1px solid var(--border);
  background: radial-gradient(600px 300px at 70% 50%, rgba(124, 92, 255, 0.35), transparent 70%),
    linear-gradient(135deg, rgba(20, 24, 50, 0.85), rgba(10, 14, 32, 0.6));
  box-shadow: var(--shadow);
}
:root[data-theme="light"] .hero { background: radial-gradient(600px 300px at 70% 50%, rgba(124, 92, 255, 0.25), transparent 70%), linear-gradient(135deg, #ffffff, #e8ecff); }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.hero-text { position: absolute; left: 32px; top: 30px; z-index: 2; pointer-events: none; max-width: 46%; }
.hero-text h2 { font-size: 34px; font-weight: 800; line-height: 1.1; }
.hero-text h2 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-text p { color: var(--muted); margin: 10px 0 0; }
.hero-hint { position: absolute; left: 32px; bottom: 22px; z-index: 2; font-size: 12px; color: var(--muted); pointer-events: none; }
.hero-label {
  position: absolute; z-index: 3; pointer-events: none; padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: var(--panel-solid); border: 1px solid var(--border); transform: translate(-50%, -140%); opacity: 0; transition: opacity 0.2s; white-space: nowrap;
}
.hero-label.show { opacity: 1; }
.hero-stat { position: absolute; z-index: 2; right: 24px; bottom: 22px; display: flex; gap: 10px; pointer-events: none; }
.hero-stat div { background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; font-size: 12px; color: var(--muted); }
.hero-stat b { display: block; font-size: 18px; color: var(--text); }

.stage3d { height: 320px; position: relative; border-radius: 14px; overflow: hidden; }
.stage3d canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.stage-tip { position: absolute; pointer-events: none; padding: 6px 10px; border-radius: 10px; background: var(--panel-solid); border: 1px solid var(--border); font-size: 12px; opacity: 0; transition: opacity 0.15s; transform: translate(-50%, -120%); white-space: nowrap; }
.stage-tip.show { opacity: 1; }

/* Forms */
input, select, textarea {
  background: var(--panel-hi); border: 1px solid var(--border); color: var(--text); padding: 10px 13px; border-radius: 12px;
  font: inherit; font-size: 14px; outline: none; transition: border 0.2s, box-shadow 0.2s; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18); }
textarea { resize: vertical; min-height: 70px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }

.btn {
  border: none; background: var(--grad); color: #fff; padding: 10px 16px; border-radius: 12px; font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: transform 0.15s, box-shadow 0.2s, filter 0.2s; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 25px -10px var(--accent); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn.ghost { background: var(--panel-hi); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: linear-gradient(135deg, #ff5c7a, #ff8a5c); }
.btn.success { background: linear-gradient(135deg, #22d39a, #00b8d4); }
.btn.small { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.icon-btn { background: var(--panel-hi); border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 15px; display: inline-grid; place-items: center; transition: all 0.15s; }
.icon-btn:hover { transform: scale(1.1); border-color: var(--accent); }

.tabs { display: inline-flex; background: var(--panel-hi); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; }
.tabs button { border: none; background: transparent; color: var(--muted); padding: 7px 13px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.tabs button.on { background: var(--grad); color: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tr { transition: background 0.15s; }
tbody tr:hover { background: var(--panel-hi); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-hi); border: 1px solid var(--border); white-space: nowrap; }
.chip.ok { background: rgba(34, 211, 154, 0.15); color: var(--green); border-color: transparent; }
.chip.warn { background: rgba(255, 201, 77, 0.15); color: var(--yellow); border-color: transparent; }
.chip.bad { background: rgba(255, 92, 122, 0.15); color: var(--red); border-color: transparent; }
.chip.info { background: rgba(0, 212, 255, 0.13); color: var(--accent2); border-color: transparent; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0; }
.who { display: flex; align-items: center; gap: 10px; }
.who small { display: block; color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 13px; background: var(--panel-hi); border: 1px solid var(--border); transition: transform 0.15s; }
.li:hover { transform: translateX(4px); }
.li .time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 52px; }
.li .grow { flex: 1; min-width: 0; }
.li .grow small { color: var(--muted); display: block; }

/* Progress */
.bar { height: 8px; background: var(--panel-hi); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar.red > i { background: linear-gradient(90deg, #ff5c7a, #ff9f43); }

/* Calendar / agenda */
.agenda { display: grid; grid-template-columns: 60px repeat(var(--cols), minmax(140px, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: auto; max-height: 640px; position: relative; }
.agenda .ah { position: sticky; top: 0; z-index: 3; background: var(--panel-solid); padding: 10px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.agenda .ah:first-child { border-left: none; }
.agenda .hcell { font-size: 11px; color: var(--muted); padding: 4px 6px; height: 56px; border-bottom: 1px dashed var(--border); text-align: right; }
.agenda .col { position: relative; border-left: 1px solid var(--border); }
.agenda .slot { height: 56px; border-bottom: 1px dashed var(--border); cursor: pointer; transition: background 0.15s; }
.agenda .slot:hover { background: rgba(124, 92, 255, 0.12); }
.agenda .ev {
  position: absolute; left: 4px; right: 4px; border-radius: 10px; padding: 6px 8px; font-size: 12px; color: #fff; overflow: hidden; cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.6); transition: transform 0.15s, box-shadow 0.15s; z-index: 2; line-height: 1.25;
}
.agenda .ev:hover { transform: scale(1.03) translateZ(0); z-index: 4; box-shadow: 0 14px 28px -10px rgba(0, 0, 0, 0.7); }
.agenda .ev b { display: block; font-size: 12.5px; }
.agenda .ev.done { opacity: 0.55; }
.agenda .ev.cancel { opacity: 0.35; text-decoration: line-through; }
.agenda .now { position: absolute; left: 0; right: 0; height: 2px; background: var(--pink); z-index: 3; pointer-events: none; }
.agenda .now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--pink); }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month .dh { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; padding: 4px; }
.month .d { min-height: 86px; border-radius: 12px; background: var(--panel-hi); border: 1px solid var(--border); padding: 6px 8px; cursor: pointer; transition: transform 0.15s, border 0.15s; font-size: 12px; }
.month .d:hover { transform: translateY(-3px); border-color: var(--accent); }
.month .d.other { opacity: 0.35; }
.month .d.today { border-color: var(--accent2); box-shadow: inset 0 0 0 1px var(--accent2); }
.month .d .n { font-weight: 700; font-size: 13px; }
.month .d .dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.month .d .dots i { width: 7px; height: 7px; border-radius: 50%; }

/* POS */
.pos-grid { display: grid; grid-template-columns: 1fr 380px; gap: 18px; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.prod {
  padding: 16px 14px; border-radius: 16px; background: var(--panel-hi); border: 1px solid var(--border); cursor: pointer; text-align: left;
  color: var(--text); font: inherit; transition: transform 0.2s, border 0.2s; position: relative; overflow: hidden;
}
.prod:hover { border-color: var(--accent); }
.prod .pe { font-size: 28px; display: block; margin-bottom: 8px; transform: translateZ(25px); }
.prod b { display: block; font-size: 14px; }
.prod span { color: var(--accent2); font-weight: 700; font-size: 15px; }
.prod.pop { animation: pop 0.35s; }
@keyframes pop { 50% { transform: scale(0.93); } }
.ticket { position: sticky; top: 18px; display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.ticket .lines { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin: 10px 0; min-height: 120px; }
.ticket .line { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--panel-hi); font-size: 14px; animation: viewIn 0.25s; }
.ticket .total { font-size: 32px; font-weight: 800; display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: 1px dashed var(--border); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
.kcol { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px; min-height: 360px; transition: background 0.2s; }
.kcol.over { background: rgba(124, 92, 255, 0.15); }
.kcol h4 { font-size: 14px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kcard { background: var(--panel-hi); border: 1px solid var(--border); border-radius: 12px; padding: 11px; margin-bottom: 8px; cursor: grab; font-size: 14px; transition: transform 0.15s, box-shadow 0.15s; }
.kcard:hover { transform: translateY(-2px) rotate(-0.6deg); box-shadow: var(--shadow); }
.kcard.dragging { opacity: 0.4; }
.kcard small { color: var(--muted); display: flex; gap: 8px; margin-top: 6px; align-items: center; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; height: calc(100vh - 140px); min-height: 520px; }
.chat-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-item { padding: 11px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.chat-item:hover { background: var(--panel-hi); }
.chat-item.on { background: var(--panel-hi); border-color: var(--accent); }
.chat-item small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.bot-orb { width: 42px; height: 42px; border-radius: 50%; background: conic-gradient(from 0deg, var(--accent), var(--accent2), var(--pink), var(--accent)); animation: spin 6s linear infinite; position: relative; flex-shrink: 0; }
.bot-orb::after { content: "🤖"; position: absolute; inset: 3px; border-radius: 50%; background: var(--panel-solid); display: grid; place-items: center; font-size: 19px; animation: spin 6s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.msgs { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; animation: msgIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); white-space: pre-wrap; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
.msg.bot { background: var(--panel-hi); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.user { background: var(--grad); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg.staff { background: linear-gradient(135deg, #22d39a, #00b8d4); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg time { display: block; font-size: 10px; opacity: 0.6; margin-top: 4px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 18px 10px; }
.quick button { border: 1px solid var(--border); background: var(--panel-hi); color: var(--text); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; transition: all 0.15s; }
.quick button:hover { border-color: var(--accent); transform: translateY(-2px); }
.chat-input { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin: 0 2px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* Chat widget for customers */
.widget-btn { position: fixed; right: 24px; bottom: 24px; z-index: 60; width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer; background: var(--grad); color: #fff; font-size: 26px; box-shadow: 0 15px 35px -10px var(--accent); animation: float 4s ease-in-out infinite; }
.widget { position: fixed; right: 24px; bottom: 96px; z-index: 60; width: 370px; height: 540px; max-height: calc(100vh - 120px); display: none; }
.widget.open { display: flex; animation: viewIn 0.3s; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 7, 18, 0.55); backdrop-filter: blur(6px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.open { display: flex; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel-solid); border: 1px solid var(--border); border-radius: 22px; padding: 24px; width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7); animation: modalIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes modalIn { from { opacity: 0; transform: perspective(800px) rotateX(12deg) translateY(30px) scale(0.95); } }
.modal h2 { font-size: 21px; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toasts */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel-solid); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3); max-width: 340px; }
.toast.ok { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }

/* Charts */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .tt { position: absolute; pointer-events: none; background: var(--panel-solid); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 12px; opacity: 0; transition: opacity 0.15s; white-space: nowrap; z-index: 5; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bigbalance { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; }

.biz-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.biz { padding: 18px 12px; text-align: center; border-radius: 16px; background: var(--panel-hi); border: 2px solid var(--border); cursor: pointer; transition: all 0.2s; color: var(--text); font: inherit; }
.biz .e { font-size: 34px; display: block; margin-bottom: 6px; }
.biz.on { border-color: var(--accent); background: rgba(124, 92, 255, 0.18); }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.qa { padding: 14px; border-radius: 14px; background: var(--panel-hi); border: 1px solid var(--border); cursor: pointer; text-align: left; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; transition: all 0.2s; position: relative; overflow: hidden; }
.qa .e { font-size: 22px; display: block; margin-bottom: 6px; }
.qa:hover { border-color: var(--accent); }

@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span3 { grid-column: span 2; }
  .pos-grid { grid-template-columns: 1fr; }
  .ticket { position: static; max-height: none; }
  .search input { width: 200px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 90; width: 260px; transform: translateX(-100%); transition: transform 0.3s; background: var(--panel-solid); }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-grid; }
  .main { padding: 14px 16px 40px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .search, .clock { display: none; }
  .hero { height: 380px; }
  .hero-text { max-width: 90%; left: 20px; top: 20px; }
  .hero-text h2 { font-size: 26px; }
  .hero-stat { left: 16px; right: 16px; bottom: 16px; justify-content: flex-start; flex-wrap: wrap; }
  .hero-hint { display: none; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat { height: 70vh; }
  .form { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 80vw); }
  .widget { right: 12px; left: 12px; width: auto; }
  .topbar h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Kupla: acceso, modos y portal ---------- */
[hidden] { display: none !important; }
#acceso, .auth-wrap { position: fixed; inset: 0; z-index: 150; overflow: auto; }
.auth-wrap { display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 40px; background: radial-gradient(900px 600px at 80% -10%, rgba(124, 92, 255, 0.3), transparent 60%), var(--bg); }
.auth-card { width: 440px; max-width: 100%; animation: modalIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.auth-card h2 { font-size: 22px; }
.auth-msg { padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.auth-msg.bad { background: rgba(255, 92, 122, 0.14); color: var(--red); }
.auth-msg.ok { background: rgba(34, 211, 154, 0.14); color: var(--green); }
.auth-card code { background: var(--panel-hi); padding: 2px 6px; border-radius: 6px; font-size: 12px; word-break: break-all; }
.mode-banner { background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(0, 212, 255, 0.12)); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.mode-banner.warn { background: rgba(255, 201, 77, 0.15); border-color: rgba(255, 201, 77, 0.5); }
.sync-state { align-self: center; white-space: nowrap; }
.sync-state[data-estado="error"] { color: var(--red); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
details summary { cursor: pointer; color: var(--muted); }

/* Portal del cliente (pensado para móvil) */
.portal { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; position: relative; z-index: 1; }
.portal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.portal-head h1 { font-size: 20px; }
.portal-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; justify-content: center; gap: 2px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--panel-solid); border-top: 1px solid var(--border); }
.portal-tabs button { flex: 1; max-width: 120px; border: none; background: transparent; color: var(--muted); font: inherit; font-size: 11px; padding: 6px 2px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.portal-tabs button span { font-size: 20px; }
.portal-tabs button.on { color: var(--text); background: rgba(124, 92, 255, 0.18); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.slots button, .dias button { border: 1px solid var(--border); background: var(--panel-hi); color: var(--text); border-radius: 12px; padding: 10px 6px; font: inherit; font-weight: 600; cursor: pointer; }
.slots button.on, .dias button.on { background: var(--grad); color: #fff; border-color: transparent; }
.dias { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.dias button { min-width: 64px; display: flex; flex-direction: column; align-items: center; font-size: 12px; }
.dias button b { font-size: 18px; }
.portal .chat { height: calc(100vh - 230px); min-height: 420px; }

/* Landing */
.land-nav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.land-nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.land-nav a:hover { color: var(--text); }
.land { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 24px 60px; }
.land-hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 20px; align-items: center; min-height: 78vh; }
.land-hero h1 { font-size: clamp(36px, 5.4vw, 64px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 800; }
.land-hero h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.land-hero p { font-size: 18px; color: var(--muted); max-width: 520px; }
.land-3d { height: 520px; position: relative; border-radius: 28px; overflow: hidden; }
.land-3d canvas { width: 100%; height: 100%; display: block; }
.land h2.sec { font-size: clamp(28px, 3.4vw, 42px); text-align: center; margin: 90px 0 10px; letter-spacing: -0.03em; }
.land p.sec { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 34px; }
.feat { padding: 22px; }
.feat .e { font-size: 34px; display: block; margin-bottom: 10px; transform: translateZ(40px); }
.feat h3 { margin-bottom: 6px; }
.feat p { color: var(--muted); font-size: 14px; margin: 0; }
.precio { text-align: center; padding: 28px 22px; }
.precio .cifra { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; }
.precio ul { text-align: left; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.precio.dest { border-color: var(--accent); box-shadow: 0 30px 60px -30px var(--accent); }
.land-foot { border-top: 1px solid var(--border); margin-top: 80px; padding: 28px 0; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }
.land-foot a { color: var(--muted); }
.cookie { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 80; max-width: 560px; margin: 0 auto; }
.phone { width: 270px; height: 540px; border-radius: 40px; border: 10px solid #0b0e1f; background: var(--bg2); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.7); overflow: hidden; margin: auto; position: relative; }
.phone iframe { width: 100%; height: 100%; border: 0; }
@media (max-width: 860px) {
  .land-hero { grid-template-columns: 1fr; min-height: auto; padding-top: 30px; }
  .land-3d { height: 360px; }
  .land-nav { padding: 12px 16px; gap: 12px; }
  .land-nav .hide-m { display: none; }
}

/* Documentos legales */
.legal { max-width: 860px; margin: 0 auto; padding: 32px 20px 80px; position: relative; z-index: 1; line-height: 1.65; }
.legal h1 { font-size: 30px; margin-bottom: 4px; }
.legal h2 { font-size: 19px; margin: 28px 0 8px; }
.legal .aviso { border: 1px solid rgba(255, 201, 77, 0.6); background: rgba(255, 201, 77, 0.12); border-radius: 12px; padding: 12px 16px; font-size: 14px; }
.legal table { margin: 10px 0; }
.legal td, .legal th { vertical-align: top; }
@media print { .legal .aviso, .land-nav, #bg3d { display: none; } body { background: #fff; color: #000; } }

/* Ajustes de formularios */
.form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form select, .form input:not([type="checkbox"]):not([type="radio"]), .form textarea { width: 100%; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; padding: 0; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; box-shadow: none; cursor: pointer; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
@media (max-width: 860px) { .form { grid-template-columns: minmax(0, 1fr); } }
a.btn { text-decoration: none; }

/* Landing: pasos, portátil y sectores */
.pasos .feat { position: relative; }
.paso-n { position: absolute; top: 16px; right: 18px; width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.laptop { max-width: 980px; margin: 10px auto 0; }
.laptop-pantalla { border: 12px solid #0b0e1f; border-bottom-width: 18px; border-radius: 18px 18px 0 0; aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg2); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.7); }
.laptop-pantalla iframe { width: 166.66%; height: 166.66%; border: 0; transform: scale(0.6); transform-origin: 0 0; }
.laptop-base { height: 16px; margin: 0 -40px; border-radius: 0 0 16px 16px; background: linear-gradient(#2a2f52, #151a33); }
a.sector { text-decoration: none; color: inherit; }
a.sector span.small { color: var(--accent2); font-weight: 600; display: block; margin-top: 10px; }
@media (max-width: 860px) { .laptop-base { margin: 0 -12px; } .laptop-pantalla { border-width: 6px; border-bottom-width: 10px; } }
.demo-cta { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; max-width: 980px; margin: 10px auto 0; background: linear-gradient(135deg, rgba(124, 92, 255, 0.28), rgba(0, 212, 255, 0.12)); }
.demo-cta .e { font-size: 42px; }
.demo-cta .grow { flex: 1; min-width: 240px; }
.demo-cta p { margin: 4px 0 0; }
