:root {
  --bg: #0b1020;
  --panel: #111827;
  --panel-2: #162033;
  --line: #253047;
  --text: #eef4ff;
  --muted: #93a4bd;
  --blue: #4f8cff;
  --cyan: #18d4ff;
  --green: #3ee58f;
  --red: #ff6b6b;
  --shadow: 0 22px 70px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, rgba(79,140,255,.24), transparent 28%), radial-gradient(circle at 80% 0%, rgba(24,212,255,.18), transparent 25%), var(--bg);
}
button, input, textarea { font: inherit; }
button { border: 1px solid var(--line); background: #121a2b; color: var(--text); border-radius: 12px; padding: 10px 14px; cursor: pointer; transition: .18s ease; }
button:hover { border-color: var(--blue); transform: translateY(-1px); }
.primary, .upload-button { border: 0; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: white; font-weight: 800; }
.danger { color: var(--red); border-color: rgba(255,107,107,.35); }
[hidden], .dashboard-only[hidden], .menu-section[hidden] { display: none !important; }
.auth-modal-open { overflow: hidden !important; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    rgba(6, 11, 24, .96);
  background-size: 32px 32px;
  overflow: auto;
}
.auth-layout { position: relative; width: min(440px, 100%); display: grid; gap: 18px; }
.auth-close { position: absolute; top: 2px; right: 2px; z-index: 2; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 6px; background: #111827; color: #fff; font-size: 25px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand-logo-full { display: block; width: min(360px, 100%); height: auto; object-fit: contain; }
.auth-brand .brand-logo-full { width: min(380px, 92vw); max-height: 174px; }
.auth-brand strong { display: block; color: #f8fafc; font-size: 20px; }
.auth-brand span { display: block; margin-top: 2px; color: #93a4bd; font-size: 12px; }
.auth-card {
  padding: 30px;
  border: 1px solid #2d3a52;
  border-radius: 8px;
  background: #111827;
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}
.auth-heading h1 { margin: 5px 0 22px; color: #f8fafc; font-size: 26px; letter-spacing: 0; }
.auth-reason { margin: -13px 0 20px; color: #9caac0; font-size: 13px; line-height: 1.55; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border: 1px solid #2d3a52;
  border-radius: 7px;
  background: #0b1220;
}
.auth-tabs button { min-height: 38px; padding: 7px 10px; border: 0; border-radius: 5px; background: transparent; color: #9caac0; font-weight: 700; }
.auth-tabs button:hover { transform: none; color: #fff; }
.auth-tabs button.active { background: #26344c; color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.auth-form { display: grid; gap: 15px; }
.auth-form label:not(.terms-consent) { display: grid; gap: 7px; color: #dbe5f4; font-size: 13px; font-weight: 700; }
.auth-form input:not([type="checkbox"]) {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #35435d;
  border-radius: 6px;
  outline: 0;
  background: #0d1525;
  color: #f8fafc;
}
.auth-form input:not([type="checkbox"]):focus { border-color: #18d4ff; box-shadow: 0 0 0 3px rgba(24,212,255,.13); }
.auth-form label small { color: #8493aa; font-size: 11px; font-weight: 500; }
.terms-consent { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; color: #b9c5d7; font-size: 12px; line-height: 1.55; }
.terms-consent input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: #107c41; }
.terms-consent button { display: inline; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: #56d8ff; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.terms-consent button:hover { transform: none; color: #fff; }
.auth-submit { min-height: 46px; border: 0; border-radius: 6px; background: #107c41; color: #fff; font-weight: 800; }
.auth-submit:hover { background: #12934e; border-color: transparent; }
.auth-submit:disabled { cursor: wait; opacity: .65; transform: none; }
.auth-guest { width: 100%; min-height: 42px; margin-top: 14px; border-color: #35435d; border-radius: 6px; background: transparent; color: #c5d1e2; }
.auth-guest:hover { transform: none; border-color: #56d8ff; color: #fff; }
.auth-message { margin: 0; padding: 10px 12px; border: 1px solid rgba(255,107,107,.35); border-radius: 6px; background: rgba(127,29,29,.2); color: #fecaca; font-size: 12px; line-height: 1.5; }
.auth-message.success { border-color: rgba(62,229,143,.35); background: rgba(6,78,59,.25); color: #a7f3d0; }
.auth-terms-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: min(82vh, 820px);
  padding: 0;
  border: 1px solid #35435d;
  border-radius: 8px;
  background: #111827;
  color: #eef4ff;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.auth-terms-dialog::backdrop { background: rgba(3,7,18,.78); backdrop-filter: blur(4px); }
.auth-terms-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid #2d3a52; background: #111827; }
.auth-terms-head h2 { margin: 4px 0 0; font-size: 21px; }
.auth-terms-head > button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 6px; font-size: 24px; }
.auth-terms-body { padding: 4px 24px 26px; overflow: auto; color: #c5d1e2; }
.auth-terms-body .terms-content { display: block; }
.account-menu { position: relative; }
.account-trigger { min-height: 40px; display: inline-flex; align-items: center; gap: 9px; padding: 5px 10px 5px 6px; border-radius: 7px; background: #121a2b; }
.account-trigger:hover { transform: none; }
.account-avatar { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: #107c41; color: #fff; font-size: 12px; font-weight: 900; }
.account-name { max-width: 150px; overflow: hidden; color: #eef4ff; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.account-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10100; width: 250px; padding: 14px; border: 1px solid #35435d; border-radius: 7px; background: #111827; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.account-popover strong, .account-popover small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-popover small { margin-top: 4px; color: #93a4bd; }
.account-popover button { width: 100%; margin-top: 14px; border-radius: 6px; color: #fecaca; text-align: left; }
.account-popover #accountLoginBtn { border-color: #107c41; background: #107c41; color: #fff; }
.account-popover #accountRegisterBtn { margin-top: 8px; border-color: #35435d; color: #eef4ff; }

.app-shell { --sidebar-width: 280px; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .24s ease; }
.app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.menu-toggle { position: fixed; top: 50%; left: calc(var(--sidebar-width) - 32px); z-index: 10020; width: 32px; height: 68px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 0 12px 12px 0; background: rgba(11,16,32,.98); color: #fff; font-size: 30px; font-weight: 900; line-height: 1; transform: translateY(-50%); box-shadow: none; backdrop-filter: blur(14px); }
.menu-toggle .menu-symbol-open,
.menu-toggle .menu-symbol-closed { display: block; line-height: 1; }
.menu-toggle[aria-expanded="true"] .menu-symbol-closed,
.menu-toggle[aria-expanded="false"] .menu-symbol-open { display: none; }
.menu-toggle:hover { background: rgba(18,26,44,.98); transform: translateY(-50%); }
.menu-toggle[aria-expanded="false"] { left: 0; }
.app-shell.sidebar-collapsed .menu-toggle { left: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; min-width: var(--sidebar-width); padding: 22px; border-right: 1px solid var(--line); background: rgba(11,16,32,.86); backdrop-filter: blur(18px); overflow: visible; display: flex; flex-direction: column; transition: transform .24s ease, opacity .2s ease, visibility .2s ease;  z-index: 10010;}
.app-shell.sidebar-collapsed .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); opacity: 0; visibility: hidden; pointer-events: none;  z-index: 10010;}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.app-brand-logo { justify-content: center; min-height: 104px; margin-bottom: 18px; }
.app-brand-logo .brand-logo-full { width: 100%; max-width: 236px; max-height: 108px; }
.brand-mark, .spark, .upload-mark { display: grid; place-items: center; background: linear-gradient(135deg, var(--blue), var(--cyan)); font-weight: 900; box-shadow: 0 14px 30px rgba(24,212,255,.22); }
.brand-mark, .spark { width: 44px; height: 44px; border-radius: 16px; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand h1 { margin: 0; font-size: 19px; }
.brand p, .eyebrow { color: var(--muted); margin: 3px 0 0; font-size: 12px; }
.sidebar .primary { width: 100%; margin-bottom: 10px; }
.nav-list { display: grid; gap: 9px; margin-top: 8px; }
.nav-list button { width: 100%; text-align: left; background: transparent; }
.nav-list button.active, .nav-list button:hover { background: rgba(79,140,255,.16); }
.nav-list button.assistant-active { border-color: var(--blue); background: rgba(79,140,255,.16); }

.sidebar-ai-card { position: relative; z-index: 1200; width: 100%; margin-top: 22px; margin-bottom: 0; padding: 16px; border: 1px solid rgba(148,163,184,.18); border-radius: 26px; background: radial-gradient(circle at 50% 0%, rgba(79,140,255,.18), rgba(15,23,42,.96) 44%, #0b1020 100%); color: #e5e7eb; display: flex; flex-direction: column; flex: 1; min-height: 430px; box-shadow: 0 18px 50px rgba(0,0,0,.34); transition: width .24s ease, max-height .24s ease, box-shadow .24s ease, background .24s ease; }
.sidebar-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.sidebar-ai-head span { color: #f8fafc; font-weight: 900; }
.sidebar-ai-head small { color: #9ca3af; font-size: 11px; }
.sidebar-ai-head-actions { display: inline-flex; align-items: center; gap: 8px; }
.sidebar-ai-head-actions button { width: auto; min-height: 26px; padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(148,163,184,.24); background: rgba(255,255,255,.08); color: #cbd5e1; font-size: 11px; font-weight: 700; }
.sidebar-ai-head-actions button:hover { background: rgba(255,255,255,.14); color: #fff; transform: none; }

.sidebar-ai-messages { flex: 1; min-height: 300px; overflow: auto; display: grid; align-content: start; gap: 10px; margin-bottom: 14px; color: #cbd5e1; font-size: 12px; line-height: 1.48; scrollbar-color: #475569 transparent; }
.sidebar-ai-messages p { margin: 0; color: #94a3b8; }
.sidebar-chat { padding: 10px 12px; border: 1px solid rgba(148,163,184,.22); border-radius: 18px; background: rgba(255,255,255,.08); color: #e5e7eb; backdrop-filter: blur(10px); }
.sidebar-chat.user { justify-self: stretch; color: #f8fafc; background: rgba(79,140,255,.18); border-color: rgba(96,165,250,.28); }
.sidebar-chat.ai { color: #e5e7eb; background: rgba(255,255,255,.07); }
.sidebar-chat.error { color: #fecaca; }
.sidebar-ai-input { display: grid; gap: 0; position: relative; }
.sidebar-ai-compose { min-height: 64px; display: grid; grid-template-columns: 40px minmax(0, 1fr) 42px; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 999px; background: #202124; border: 1px solid rgba(255,255,255,.08); box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 18px 44px rgba(0,0,0,.28); }
.sidebar-attach-btn { width: 38px !important; min-width: 38px; min-height: 38px; height: 38px; padding: 0; border-radius: 999px; border: 0; background: transparent !important; color: #e8eaed !important; font-size: 30px; font-weight: 300; line-height: 1; }
.sidebar-attach-btn:hover { background: rgba(255,255,255,.08) !important; transform: none; }
.sidebar-ai-attachments { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.sidebar-attachment-chip { max-width: 100%; display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid rgba(148,163,184,.22); border-radius: 999px; background: rgba(255,255,255,.08); color: #e5e7eb; font-size: 11px; overflow: hidden; }
.sidebar-attachment-chip b { color: #7dd3fc; }
.sidebar-attachment-chip small { color: #94a3b8; white-space: nowrap; }
.sidebar-attachment-chip button { min-width: 20px; min-height: 20px; padding: 0; border: 0; background: transparent; color: #fecaca; font-size: 16px; }
.sidebar-ai-input textarea { width: 100%; resize: none; height: 38px; min-height: 38px; max-height: 38px; border: 0; border-radius: 0; padding: 9px 4px; color: #f8fafc; background: transparent; outline: 0; overflow: hidden; white-space: nowrap; line-height: 20px; }
.sidebar-ai-input textarea::placeholder { color: #bdc1c6; opacity: 1; }
.sidebar-ai-input > button { position: absolute; right: 28px; bottom: 24px; width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 999px; display: grid; place-items: center; background: rgba(255,255,255,.08); color: #e8eaed; font-size: 0; z-index: 5; overflow: hidden; }
.sidebar-ai-input > button::before { content: ''; width: 11px; height: 11px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); margin-left: -3px; }
.sidebar-ai-input > button:hover { background: rgba(255,255,255,.14); transform: none; }
.sidebar-ai-input > button:disabled { opacity: .55; cursor: wait; }
.sidebar-ai-card .sidebar-ai-input > button,
.sidebar-ai-card.expanded .sidebar-ai-input > button { position: absolute; right: 18px; bottom: 13px; width: 38px; height: 38px; min-height: 38px; }
.sidebar-ai-card.expanded .sidebar-ai-input > button { z-index: 6; }

.sidebar-ai-card.expanded { z-index: 10015 !important; position: fixed; left: 22px; top: 92px; bottom: 0; width: min(680px, calc(100vw - var(--sidebar-width) - 86px)); height: auto; min-height: 420px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: radial-gradient(circle at 50% 0%, rgba(79,140,255,.22), rgba(15,23,42,.97) 42%, #0b1020 100%); box-shadow: 0 28px 80px rgba(0,0,0,.42); }
.sidebar-ai-card.expanded::before { content: 'Ch\00FA ng ta n\00EA n b\1EAF t \0111 \1EA7 u t\1EEB  \0111 \00E2 u nh\1EC9 ?'; display: block; margin: 4px 0 20px; text-align: center; color: #e5e7eb; font-size: clamp(24px, 3.1vw, 38px); font-weight: 400; letter-spacing: -.02em; }
.sidebar-ai-card.expanded .sidebar-ai-head { margin-bottom: 8px; }
.sidebar-ai-card.expanded .sidebar-ai-messages { min-height: 0; flex: 1; font-size: 13px; line-height: 1.55; padding-right: 4px; }
.sidebar-ai-card.expanded .sidebar-ai-compose { min-height: 64px; }
.sidebar-ai-card.expanded .sidebar-ai-input textarea { height: 38px; min-height: 38px; max-height: 38px; overflow: hidden; }
.sidebar-ai-card.expanded .sidebar-attach-btn { min-height: 38px; }
.sidebar-ai-card.expanded > * { position: relative; z-index: 1; }
.sidebar-ai-card .ai-action-box { border-color: rgba(148,163,184,.22); background: rgba(255,255,255,.08); color: #e5e7eb; }
.sidebar-ai-card .ai-action-box h4, .sidebar-ai-card .ai-action-box li { color: #f8fafc; }
.sidebar-ai-card .ai-action-box small { color: #94a3b8; }
.sidebar-thinking { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid rgba(148,163,184,.22); border-radius: 18px; background: rgba(255,255,255,.07); color: #e5e7eb; }
.thinking-line { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.thinking-dots { display: inline-flex; gap: 4px; align-items: center; }
.thinking-dots span { width: 6px; height: 6px; border-radius: 999px; background: #7dd3fc; animation: thinking-bounce 1s infinite ease-in-out; }
.thinking-dots span:nth-child(2) { animation-delay: .16s; }
.thinking-dots span:nth-child(3) { animation-delay: .32s; }
.thinking-hints { position: relative; min-height: 18px; color: #94a3b8; font-size: 12px; }
.thinking-hints span { position: absolute; left: 0; opacity: 0; animation: thinking-hint 4.8s infinite; }
.thinking-hints span:nth-child(2) { animation-delay: 1.6s; }
.thinking-hints span:nth-child(3) { animation-delay: 3.2s; }
@keyframes thinking-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-6px); opacity: 1; } }
@keyframes thinking-hint { 0%, 12% { opacity: 0; transform: translateY(3px); } 22%, 45% { opacity: 1; transform: translateY(0); } 56%, 100% { opacity: 0; transform: translateY(-3px); } }
@media (max-width: 850px) { .sidebar-ai-card.expanded { z-index: 10015 !important; left: 14px; top: 78px; bottom: 0; width: min(92vw, 680px); height: auto; } .sidebar-ai-card.expanded::before { font-size: 24px; } }

.workspace { padding: 22px; min-width: 0; overflow: auto; transition: padding .24s ease;  position: relative; z-index: 1;}
.app-shell.sidebar-collapsed .workspace { padding-left: 76px;  position: relative; z-index: 1;}
.spreadsheet-active {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.spreadsheet-active .app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.spreadsheet-active .workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.spreadsheet-active #toolbar {
  flex: 0 0 auto;
}
.spreadsheet-active #gridSection {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
.spreadsheet-active #gridSection .sheet-wrap {
  flex: 1 1 auto;
  height: auto !important;
  min-height: 0 !important;
}
.spreadsheet-active #gridSection .sheet-tabs {
  flex: 0 0 auto;
}
.topbar, .section-title, .toolbar, .sheet-tabs { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar { margin-bottom: 18px; padding-left: 58px; min-height: 46px; }
.topbar h2, .section-title h2 { margin: 0; }
.workspace-brand { display: flex; align-items: center; gap: 8px; min-height: 34px; margin-bottom: 3px; color: #f8fafc; font-size: 13px; font-weight: 750; }
.workspace-brand img { display: block; width: 32px; height: 32px; flex: 0 0 32px; object-fit: contain; }
.workspace-brand strong { color: var(--cyan); }
.top-actions, .tool-buttons, .row-controls { display: flex; gap: 8px; flex-wrap: wrap; }

.upload-card {
  min-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 42px;
  border: 1px dashed rgba(24,212,255,.45);
  border-radius: 26px;
  background: rgba(17,24,39,.82);
  box-shadow: var(--shadow);
}
.upload-card.dragging { transform: scale(1.01); border-color: var(--cyan); background: rgba(24,212,255,.08); }
.upload-mark { width: 88px; height: 88px; border-radius: 28px; font-size: 48px; }
.upload-card h1 { margin: 0; font-size: clamp(32px, 5vw, 52px); }
.upload-card p { max-width: 560px; margin: 0; color: var(--muted); line-height: 1.6; }
.upload-button { min-width: 280px; padding: 22px 34px; border-radius: 18px; font-size: 24px; }
.fullscreen-link,
.assistant-quick-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 10px 14px; border-radius: 12px; color: #fff; text-decoration: none; font-weight: 800; white-space: nowrap; }
.fullscreen-link { background: linear-gradient(135deg, var(--blue), var(--cyan)); }
.assistant-quick-btn { gap: 8px; border-color: rgba(62,229,143,.42); background: rgba(15,23,42,.92); box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.assistant-quick-btn::before { content: ''; width: 9px; height: 9px; border-radius: 999px; background: var(--green); box-shadow: 0 0 0 4px rgba(62,229,143,.14); }
.assistant-quick-btn:hover { background: rgba(20,32,48,.96); color: #fff; transform: translateY(-1px); }
.office-dashboard { height: calc(100vh - 105px); min-height: 640px; overflow: hidden; border: 1px solid #d8dce2; border-radius: 16px; background: #fff; box-shadow: 0 10px 30px rgba(15,23,42,.12); }
.office-dashboard iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.office-close-btn { position: absolute; right: 16px; top: 16px; z-index: 20; min-height: 38px; padding: 8px 14px; border: 1px solid #cbd5e1; border-radius: 999px; background: rgba(255,255,255,.95); color: #0f172a; font-weight: 800; box-shadow: 0 10px 24px rgba(15,23,42,.18); }
.office-close-btn:hover { background: #eff6ff; border-color: #2563eb; color: #1d4ed8; }
.upload-card small { color: var(--muted); }


.excel-ribbon, .grid-card, .template-card, .ai-panel { border: 1px solid #d8dce2; background: #f8f9fb; box-shadow: 0 10px 30px rgba(15,23,42,.12); }
.excel-ribbon { color: #111827; border-radius: 0; padding: 0; margin: -22px -22px 0; border-left: 0; border-right: 0; border-top: 0; }
.excel-titlebar { min-height: 44px; display: grid; grid-template-columns: minmax(230px, 1fr) minmax(260px, 460px) minmax(300px, 1fr); align-items: center; gap: 16px; padding: 6px 10px; background: #f7f7f7; border-bottom: 1px solid #e5e7eb; }
.excel-left, .excel-right, .excel-tabs, .excel-tools, .excel-formula-row, .excel-quick-actions, .sheet-tabs, .sheet-tab-list { display: flex; align-items: center; gap: 8px; }
.sheet-ai-button {
  position: relative;
  min-width: 48px;
  min-height: 36px;
  padding: 0 14px;
  border: 3px solid #22c55e;
  border-radius: 7px;
  background: #111827;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 3px 10px rgba(15,23,42,.24);
  animation: sheet-ai-border-cycle 2.4s linear infinite;
}
.sheet-ai-button:hover { background: #107c41; color: #fff; transform: translateY(-1px) scale(1.04); }
.sheet-ai-button:focus-visible { outline: 3px solid #111827; outline-offset: 2px; }
@keyframes sheet-ai-border-cycle {
  0% { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.18), 0 3px 10px rgba(15,23,42,.24); }
  33% { border-color: #06b6d4; box-shadow: 0 0 0 2px rgba(6,182,212,.18), 0 3px 10px rgba(15,23,42,.24); }
  66% { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,.18), 0 3px 10px rgba(15,23,42,.24); }
  100% { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.18), 0 3px 10px rgba(15,23,42,.24); }
}
@media (prefers-reduced-motion: reduce) {
  .sheet-ai-button { animation: none; }
}
.app-grid { font-size: 22px; letter-spacing: -4px; transform: rotate(90deg); color: #111827; }
.excel-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; background: #107c41; color: #fff; font-weight: 900; font-size: 13px; }
.book-name { font-size: 14px; color: #111827; }
.cloud-ok { color: #107c41; font-size: 14px; }
.excel-search { justify-self: center; width: 100%; padding: 9px 14px; color: #475569; background: #fff; border: 1px solid #d8dce2; border-radius: 6px; box-shadow: inset 0 1px 2px rgba(0,0,0,.03); font-size: 13px; }
.excel-right { justify-content: flex-end; }
.excel-right button, .excel-tools button, .excel-tools select, .excel-formula-row button, .excel-quick-actions button { min-height: 28px; padding: 5px 10px; border-radius: 5px; border: 1px solid #d1d5db; background: #fff; color: #111827; box-shadow: none; }
.excel-right .share-btn { background: #107c41; color: #fff; border-color: #107c41; }
.excel-right .account-menu { margin-left: 2px; }
.excel-right .account-trigger { min-height: 32px; padding: 2px 8px 2px 3px; border-color: #2d3a52; background: #111827; color: #fff; }
.excel-right .account-avatar { width: 26px; height: 26px; }
.excel-right .account-name { color: #fff; }
.excel-right .account-popover { color: #eef4ff; text-align: left; }
.excel-right .account-popover button { min-height: 36px; padding: 7px 10px; border-color: #4b2730; background: #20151a; color: #fecaca; }
.excel-tabs { padding: 8px 16px 4px; background: #f7f7f7; border-bottom: 1px solid #e5e7eb; gap: 20px; overflow-x: auto; }
.excel-tabs button { padding: 4px 0 7px; border: 0; border-radius: 0; background: transparent; color: #111827; white-space: nowrap; }
.excel-tabs button.active { font-weight: 700; border-bottom: 3px solid #107c41; }
.excel-ribbon { position: relative; }
.ribbon-command-panel {
  position: fixed;
  top: var(--ribbon-menu-top, 96px);
  left: var(--ribbon-menu-left, 16px);
  z-index: 10040;
  width: min(318px, calc(100vw - 16px));
  max-height: min(70vh, 520px);
  display: block;
  padding: 6px 0;
  border: 1px solid #dadce0;
  border-radius: 4px;
  background: #fff;
  color: #202124;
  box-shadow: 0 8px 18px rgba(60,64,67,.28), 0 2px 6px rgba(60,64,67,.18);
  overflow: auto;
}
.ribbon-command-panel[hidden] { display: none !important; }
.ribbon-command-copy {
  display: grid;
  gap: 2px;
  padding: 8px 18px 10px;
  border-bottom: 1px solid #edf0f2;
}
.ribbon-command-copy strong { overflow: hidden; color: #188038; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.ribbon-command-copy span { color: #5f6368; font-size: 11px; line-height: 1.35; }
.ribbon-command-actions {
  display: grid;
  gap: 0;
  padding: 6px 0;
}
.ribbon-command-actions button,
.ribbon-panel-close {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 7px 18px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #202124;
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.ribbon-command-actions button:hover,
.ribbon-panel-close:hover {
  background: #f1f3f4;
  color: #202124;
  transform: none;
}
.ribbon-command-actions button.primary-command {
  background: #fff;
  color: #188038;
  font-weight: 650;
}
.ribbon-command-actions button.primary-command:hover { background: #e6f4ea; color: #137333; }
.ribbon-command-actions button.danger-command {
  background: #fff;
  color: #b3261e;
}
.ribbon-command-actions button.danger-command:hover { background: #fce8e6; color: #a50e0e; }
.ribbon-panel-close { display: none; }
.ribbon-command-panel[data-state="ok"] .ribbon-command-copy span { color: #107c41; }
.ribbon-command-panel[data-state="error"] .ribbon-command-copy span { color: #b91c1c; }
@media (max-width: 760px) {
  .ribbon-command-panel {
    width: min(300px, calc(100vw - 12px));
    max-height: min(68vh, 460px);
  }
}
.excel-tools { min-height: 44px; padding: 6px 8px; background: #f5f6f8; border-bottom: 1px solid #d8dce2; overflow-x: auto; }
.excel-tools select { min-width: 90px; }
.excel-tools select:first-of-type { min-width: 150px; }
.excel-formula-row { padding: 4px 6px; background: #fff; border-bottom: 1px solid #d8dce2; }
.excel-formula-row span:first-child { min-width: 92px; padding: 5px 8px; border: 1px solid #d8dce2; border-radius: 4px; color: #111827; background: #fff; }
.excel-formula-row span:not(:first-child) { color: #64748b; }
.excel-formula-row input { flex: 1; min-height: 29px; border: 1px solid #d8dce2; border-radius: 4px; padding: 5px 10px; color: #111827; background: #fff; outline: 0; }
.excel-quick-actions { padding: 6px 8px; background: #fff; border-bottom: 1px solid #d8dce2; overflow-x: auto; }
.excel-quick-actions .danger, .sheet-delete { color: #b91c1c; border-color: #fecaca; }
.sheet-native-overlay {
  position: relative;
  z-index: 40;
  flex: 0 0 0 !important;
  width: 100%;
  height: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.sheet-native-overlay .sheet-ai-button {
  position: fixed;
  right: 24px;
  bottom: 72px;
  z-index: 1200;
}
.sheet-bridge-controls {
  display: none !important;
}
.grid-card { border-radius: 0; overflow: hidden; margin: 0 -22px -22px; background: #fff; border-left: 0; border-right: 0; border-bottom: 0; }
.sheet-wrap { position: relative; height: calc(100vh - 235px); min-height: 560px; overflow: hidden; background: #f3f4f6; }
#luckysheet { position: absolute; inset: 0; width: 100%; height: 100%; color: #111827; }
#luckysheet #luckysheet-scrollbar-x {
  height: 16px !important;
  background: #0f172a !important;
  border-top: 1px solid #334155 !important;
  border-bottom: 1px solid #020617 !important;
  scrollbar-color: #18d4ff #0f172a;
  scrollbar-width: auto;
}
#luckysheet #luckysheet-scrollbar-x::-webkit-scrollbar {
  height: 16px;
  background: #0f172a;
}
#luckysheet #luckysheet-scrollbar-x::-webkit-scrollbar-track {
  background: #0f172a;
  border-top: 1px solid #334155;
  border-bottom: 1px solid #020617;
}
#luckysheet #luckysheet-scrollbar-x::-webkit-scrollbar-thumb {
  min-width: 64px;
  border: 3px solid #0f172a;
  border-radius: 999px;
  background: #18d4ff;
  box-shadow: inset 0 0 0 1px #dff7ff;
}
#luckysheet #luckysheet-scrollbar-x::-webkit-scrollbar-thumb:hover {
  background: #4f8cff;
}
#luckysheet .ai-temp-selection {
  position: absolute;
  border-color: rgba(255, 178, 32, .96) !important;
  border-style: solid !important;
  border-width: 1px !important;
  background: rgba(255, 237, 173, .28) !important;
  box-shadow: inset 0 0 0 9999px rgba(255, 232, 138, .12), 0 0 0 1px rgba(255, 178, 32, .42) !important;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 16 !important;
}
.fallback-sheet[hidden] { display: none !important; }
.sheet-tabs { min-height: 36px; justify-content: flex-start; padding: 0 8px; border-top: 1px solid #d8dce2; border-bottom: 0; background: #f8f9fb; color: #111827; }
.sheet-nav { color: #64748b; min-width: 70px; font-size: 18px; letter-spacing: 6px; }
.sheet-tab-list { flex: 1; gap: 2px; overflow-x: auto; }
.sheet-tab-list button { min-height: 32px; padding: 6px 14px; border: 0; border-radius: 0; background: transparent; color: #111827; border-bottom: 3px solid transparent; white-space: nowrap; }
.sheet-tab-list button.active { background: #e8f4fb; border-bottom-color: #107c41; font-weight: 700; }
.sheet-plus { min-width: 32px; min-height: 28px; padding: 0; border: 0; background: transparent; color: #111827; font-size: 20px; }
.sheet-delete { min-height: 28px; padding: 4px 10px; border-radius: 5px; background: #fff; }
#sheet { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
#sheet th, #sheet td { min-width: 145px; height: 36px; padding: 7px 9px; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; font-size: 13px; color: #111827; }
#sheet th.ai-temp-highlight, #sheet td.ai-temp-highlight {
  position: relative;
  box-shadow: inset 0 0 0 9999px rgba(255, 237, 173, .20), inset 0 0 0 2px rgba(255, 178, 32, .72);
}
#sheet th.ai-temp-highlight { z-index: 2; }
#sheet th { position: sticky; top: 0; z-index: 3; color: #107c41; background: #f3f4f6; text-align: left; }
#sheet .row-head { position: sticky; left: 0; z-index: 4; min-width: 52px; width: 52px; text-align: center; color: #64748b; background: #f8fafc; }
#sheet tbody .row-head { z-index: 2; }
#sheet td { background: #fff; outline-offset: -2px; }
#sheet td:focus { outline: 2px solid #107c41; }
.cell-image { display: block; width: 112px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid #d8dce2; }
.cell-link { color: #2563eb; text-decoration: none; }
.cell-link:hover { text-decoration: underline; }
.template-card, .ai-panel { border: 1px solid var(--line); border-radius: 18px; background: rgba(17,24,39,.86); box-shadow: var(--shadow); }
.toolbar { padding: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.formula-bar { flex: 1 1 360px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #0b1220; border-radius: 14px; padding: 6px 10px; }
.formula-bar span { color: var(--cyan); font-weight: 800; min-width: 42px; }
.formula-bar input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.grid-card { overflow: hidden; }
.sheet-tabs { justify-content: flex-start; padding: 12px; border-bottom: 1px solid var(--line); }
.sheet-tabs .active { background: rgba(79,140,255,.18); }
.sheet-wrap { position: relative; height: calc(100vh - 210px); min-height: 560px; overflow: hidden; background: #0a0f1f; }
#luckysheet { position: absolute; inset: 0; width: 100%; height: 100%; color: #111827; }
.fallback-sheet[hidden] { display: none !important; }
#sheet { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
#sheet th, #sheet td { min-width: 145px; height: 36px; padding: 7px 9px; border-right: 1px solid rgba(255,255,255,.06); border-bottom: 1px solid rgba(255,255,255,.06); font-size: 13px; }
#sheet th { position: sticky; top: 0; z-index: 3; color: var(--cyan); background: #111827; text-align: left; }
#sheet .row-head { position: sticky; left: 0; z-index: 4; min-width: 52px; width: 52px; text-align: center; color: var(--muted); background: #101827; }
#sheet tbody .row-head { z-index: 2; }
#sheet td { background: rgba(13,20,36,.95); outline-offset: -2px; }
#sheet td:focus { outline: 2px solid var(--cyan); }
.cell-image { display: block; width: 112px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid rgba(255,255,255,.16); }
.cell-link { color: var(--cyan); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

.template-card, .ai-panel { padding: 14px; margin-bottom: 14px; }
.storage-card { padding: 18px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(17,24,39,.86); box-shadow: var(--shadow); }
.storage-actions, .storage-row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.storage-list { display: grid; gap: 10px; margin-top: 18px; }
.storage-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(22,32,51,.72); }
.storage-file-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: #107c41; color: #fff; font-weight: 900; }
.storage-file-info { min-width: 0; display: grid; gap: 5px; }
.storage-file-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-file-info span { color: var(--muted); font-size: 12px; }
.storage-button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; background: #121a2b; }
.storage-button.primary { border: 0; }
.storage-empty { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.storage-empty strong { color: var(--text); font-size: 18px; }
.storage-error { color: var(--red); }
@media (max-width: 760px) { .storage-row { grid-template-columns: 42px minmax(0, 1fr); } .storage-row-actions { grid-column: 1 / -1; } }
.menu-section { max-width: 1180px; }
.terms-section {
  width: min(100%, 1040px);
  margin: 0 auto 28px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17,24,39,.94);
  box-shadow: var(--shadow);
}
.terms-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.terms-head h2 { margin: 4px 0 0; font-size: 28px; }
.terms-content { display: grid; gap: 0; color: #dbe5f4; }
.terms-content section { padding: 24px 0; border-bottom: 1px solid rgba(148,163,184,.17); }
.terms-content section:last-child { border-bottom: 0; padding-bottom: 0; }
.terms-content h3 { margin: 0 0 12px; color: #f8fafc; font-size: 18px; line-height: 1.4; }
.terms-content p, .terms-content li { color: #c5d1e2; line-height: 1.75; }
.terms-content p { margin: 10px 0 0; }
.terms-content ul { margin: 12px 0 0; padding-left: 24px; }
.terms-content li + li { margin-top: 8px; }
.terms-content strong { color: #fff; }
@media (max-width: 700px) {
  .terms-section { padding: 18px; }
  .terms-head { align-items: stretch; flex-direction: column; }
  .terms-head button { align-self: flex-start; }
  .terms-content h3 { font-size: 16px; }
}
.floating-assistant {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10030;
  width: 430px;
  height: min(640px, calc(100vh - 48px));
  min-width: 330px;
  min-height: 300px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
  overflow: hidden;
  resize: none;
  border: 1px solid #344054;
  border-radius: 8px;
  background: #11151c;
  box-shadow: 0 24px 70px rgba(0,0,0,.48);
}
.assistant-resize-handle { position: absolute; z-index: 9; touch-action: none; }
.resize-n, .resize-s { left: 12px; right: 12px; height: 8px; }
.resize-e, .resize-w { top: 12px; bottom: 12px; width: 8px; }
.resize-n { top: 0; cursor: ns-resize; }
.resize-s { bottom: 0; cursor: ns-resize; }
.resize-e { right: 0; cursor: ew-resize; }
.resize-w { left: 0; cursor: ew-resize; }
.resize-ne, .resize-se, .resize-sw, .resize-nw { width: 16px; height: 16px; z-index: 10; }
.resize-ne { top: 0; right: 0; cursor: nesw-resize; }
.resize-se { right: 0; bottom: 0; cursor: nwse-resize; }
.resize-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.resize-nw { top: 0; left: 0; cursor: nwse-resize; }
.resize-se::before, .resize-se::after { content: ''; position: absolute; right: 4px; bottom: 4px; border-right: 2px solid #64748b; border-bottom: 2px solid #64748b; }
.resize-se::before { width: 10px; height: 10px; }
.resize-se::after { width: 5px; height: 5px; }
.floating-assistant.minimized .assistant-resize-handle { display: none; }
.floating-assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid #303744;
  background: #18202b;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.floating-assistant-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.floating-assistant-title > div { display: grid; gap: 2px; min-width: 0; }
.floating-assistant-title strong { overflow: hidden; color: #f8fafc; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.floating-assistant-title small { color: #94a3b8; font-size: 10px; }
.assistant-status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 999px; background: #3ee58f; box-shadow: 0 0 0 4px rgba(62,229,143,.12); }
.floating-assistant-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.floating-assistant-actions button { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 5px; border-color: transparent; background: transparent; color: #cbd5e1; font-size: 19px; line-height: 1; }
.floating-assistant-actions button:first-child { width: auto; padding: 0 8px; font-size: 11px; font-weight: 700; }
.floating-assistant-actions button:hover { transform: none; border-color: #475569; background: #252e3a; color: #fff; }
.floating-assistant.minimized { width: 300px !important; height: 54px !important; min-width: 300px; min-height: 54px; resize: none; }
.floating-assistant.minimized .floating-assistant-head { border-bottom: 0; }
.floating-assistant.minimized .assistant-chat-card { display: none; }
.assistant-chat-card.sidebar-ai-card {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: #11151c;
  box-shadow: none;
}
.assistant-chat-card .sidebar-ai-messages { min-height: 0; padding: 2px 4px 2px 0; font-size: 13px; line-height: 1.55; }
.assistant-chat-card .sidebar-chat { max-width: 92%; border-radius: 7px; }
.assistant-chat-card .sidebar-chat.user { justify-self: end; background: #19345d; border-color: #315b91; }
.assistant-chat-card .sidebar-chat.ai { justify-self: start; background: #1c222c; border-color: #353e4c; }
.assistant-chat-card .sidebar-ai-compose { border-radius: 7px; background: #20242b; border-color: #3b424d; }
.assistant-chat-card .sidebar-ai-input textarea { white-space: normal; }
.assistant-chat-card .ai-action-box { border-color: #3b424d; background: #1c222c; color: #e5e7eb; }
.assistant-chat-card .ai-action-box h4, .assistant-chat-card .ai-action-box li { color: #f8fafc; }
.assistant-chat-card .ai-action-box small { color: #9ca3af; }
@media (max-width: 700px) {
  .floating-assistant { right: 10px; bottom: 10px; width: calc(100vw - 20px); height: min(620px, calc(100vh - 20px)); min-width: 280px; min-height: 260px; max-width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .floating-assistant.minimized { width: min(300px, calc(100vw - 20px)) !important; min-width: min(280px, calc(100vw - 20px)); }
  .assistant-chat-card.sidebar-ai-card { padding: 11px; }
  .assistant-chat-card .sidebar-chat { max-width: 96%; }
}
.template-library-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 360px); gap: 14px; align-items: center; margin: 14px 0 18px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(11,18,32,.72); }
.template-library-toolbar strong { display: block; color: var(--text); margin-bottom: 4px; }
.template-library-toolbar span { color: var(--muted); font-size: 13px; }
.template-library-toolbar input { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; color: var(--text); background: #0b1220; outline: 0; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.template-groups { display: grid; gap: 18px; }
.template-group { border: 1px solid rgba(255,255,255,.08); border-radius: 20px; padding: 14px; background: rgba(11,18,32,.55); }
.template-group.planning { background: linear-gradient(135deg, rgba(132,180,20,.13), rgba(24,212,255,.05)); }
.template-group.tax { background: linear-gradient(135deg, rgba(31,111,235,.15), rgba(124,58,237,.07)); border-color: rgba(96,165,250,.28); }
.template-group.import-export { background: linear-gradient(135deg, rgba(15,118,110,.16), rgba(245,158,11,.07)); border-color: rgba(45,212,191,.24); }
.template-group.inventory { background: linear-gradient(135deg, rgba(22,163,74,.14), rgba(245,158,11,.06)); border-color: rgba(74,222,128,.24); }
.template-group-title { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.template-group-title span { color: var(--cyan); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.template-group-title p { color: var(--muted); margin: 0; font-size: 13px; max-width: 680px; }
.template-item { border: 1px solid var(--line); border-radius: 18px; padding: 12px; background: rgba(22,32,51,.72); transition: .18s ease; display: flex; flex-direction: column; min-height: 335px; }
.template-item:hover { border-color: rgba(24,212,255,.6); transform: translateY(-2px); box-shadow: 0 18px 36px rgba(0,0,0,.24); }
.template-thumb { aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); background: #0b1220; margin-bottom: 12px; }
.template-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.template-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.template-meta small { color: var(--muted); font-weight: 800; }
.template-item span { color: var(--cyan); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.template-item h3 { margin: 8px 0 6px; font-size: 16px; line-height: 1.3; }
.template-item p { color: var(--muted); min-height: 58px; line-height: 1.45; margin: 0 0 12px; font-size: 13px; }
.template-item button { width: 100%; background: rgba(79,140,255,.18); margin-top: auto; }
.template-empty, .template-loading { grid-column: 1 / -1; min-height: 120px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
@media (max-width: 760px) { .template-library-toolbar { grid-template-columns: 1fr; } .template-group-title { display: block; } }
.ai-header { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.ai-header h3 { margin: 0; }
.ai-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.prompt-box { display: grid; gap: 10px; }
.prompt-box textarea { width: 100%; min-height: 130px; resize: vertical; border: 1px solid var(--line); border-radius: 16px; padding: 12px; color: var(--text); background: #0b1220; outline: 0; }
.quick-prompts { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 8px; margin: 14px 0; }
.quick-prompts button { padding: 9px; font-size: 12px; }
.ai-output, .ai-builder { border: 1px solid var(--line); border-radius: 16px; background: rgba(22,32,51,.75); padding: 14px; color: var(--muted); line-height: 1.55; }
.ai-output h4, .ai-builder h4 { margin: 0 0 8px; color: var(--text); }
.ai-output h4 span { color: var(--cyan); font-size: 12px; font-weight: 700; margin-left: 8px; }
.ai-output b { color: var(--text); }
.ai-output pre { overflow: auto; max-height: 260px; padding: 12px; border-radius: 12px; background: #0b1220; color: var(--text); white-space: pre-wrap; }
.ai-output details { margin-top: 12px; }
.ai-warning { color: var(--red); }
.ai-action-box { margin-top: 12px; padding: 12px; border: 1px solid rgba(24,212,255,.28); border-radius: 14px; background: rgba(11,18,32,.72); }
.ai-action-box h4 { margin: 0 0 8px; color: var(--text); }
.ai-action-box ul { margin: 0 0 10px; padding-left: 18px; }
.ai-action-box li { margin: 7px 0; color: var(--text); }
.ai-action-box small { display: block; color: var(--muted); margin-top: 2px; }
.ai-action-box button { width: 100%; }
.ai-execution-card h4 { display: flex; align-items: center; gap: 8px; }
.ai-execution-mark { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 0 4px rgba(56,189,248,.14); }
.ai-execution-card[data-state="running"] .ai-execution-mark { animation: execution-pulse 1s ease-in-out infinite; }
.ai-execution-card[data-state="done"] { border-color: rgba(34,197,94,.42); }
.ai-execution-card[data-state="done"] .ai-execution-mark { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.14); }
.ai-execution-result { margin-top: 10px; padding: 9px 11px; border: 1px solid rgba(148,163,184,.22); border-radius: 7px; background: rgba(255,255,255,.06); color: #cbd5e1; font-size: 12px; font-weight: 700; }
.ai-execution-card[data-state="done"] .ai-execution-result { border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.1); color: #bbf7d0; }
@keyframes execution-pulse { 50% { opacity: .45; transform: scale(.8); } }
.ai-office-chart-panel { position: absolute; right: 18px; bottom: 18px; z-index: 12; width: min(560px, calc(100% - 36px)); height: 340px; padding: 12px; border: 1px solid #d8dce2; border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 16px 45px rgba(15,23,42,.2); }
.ai-office-chart-panel[hidden] { display: none !important; }
.ai-office-chart-panel canvas { width: 100% !important; height: calc(100% - 38px) !important; }
.office-dashboard { position: relative; }
.ai-builder { margin-top: 14px; }
.ai-builder p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.builder-actions { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 8px; }

@media (max-width: 1180px) { .app-shell { --sidebar-width: 230px; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); } .app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); } .template-grid { grid-template-columns: repeat(2, minmax(190px, 1fr)); } }
@media (max-width: 850px) { .app-shell { --sidebar-width: min(280px, 82vw); grid-template-columns: 0 1fr; } .app-shell:not(.sidebar-collapsed) { grid-template-columns: 0 1fr; } .sidebar { position: fixed; left: 0; z-index: 10010; } .app-shell:not(.sidebar-collapsed) .sidebar { transform: translateX(0); opacity: 1; visibility: visible; pointer-events: auto;  z-index: 10010;} .app-shell.sidebar-collapsed .workspace, .workspace { padding-left: 76px;  position: relative; z-index: 1;} .topbar, .section-title, .toolbar { align-items: stretch; flex-direction: column; } .top-actions, .tool-buttons, .row-controls { width: 100%; } .template-grid, .quick-prompts, .builder-actions { grid-template-columns: 1fr; } .upload-button { width: 100%; min-width: 0; } }

/* Excel-like final overrides */
.excel-ribbon { color: #111827 !important; border-radius: 0 !important; padding: 0 !important; margin: -22px -22px 0 !important; border: 0 !important; border-bottom: 1px solid #d8dce2 !important; background: #f7f7f7 !important; box-shadow: none !important; }
.excel-ribbon button:hover { transform: none; }
.excel-titlebar { min-height: 44px; display: grid; grid-template-columns: minmax(230px, 1fr) minmax(260px, 460px) minmax(300px, 1fr); align-items: center; gap: 16px; padding: 6px 10px; background: #f7f7f7; border-bottom: 1px solid #e5e7eb; }
.excel-left, .excel-right, .excel-tabs, .excel-tools, .excel-formula-row, .excel-quick-actions, .sheet-tabs, .sheet-tab-list { display: flex; align-items: center; gap: 8px; }
.app-grid { font-size: 22px; letter-spacing: -4px; transform: rotate(90deg); color: #111827; }
.excel-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; background: #107c41; color: #fff; font-weight: 900; font-size: 13px; }
.book-name { font-size: 14px; color: #111827; }
.cloud-ok { color: #107c41; font-size: 14px; }
.excel-search { justify-self: center; width: 100%; padding: 9px 14px; color: #475569; background: #fff; border: 1px solid #d8dce2; border-radius: 6px; box-shadow: inset 0 1px 2px rgba(0,0,0,.03); font-size: 13px; }
.excel-right { justify-content: flex-end; }
.excel-right button, .excel-tools button, .excel-tools select, .excel-formula-row button, .excel-quick-actions button { min-height: 28px; padding: 5px 10px; border-radius: 5px; border: 1px solid #d1d5db; background: #fff; color: #111827; box-shadow: none; }
.excel-right .share-btn { background: #107c41; color: #fff; border-color: #107c41; }
.excel-tabs { padding: 8px 16px 4px; background: #f7f7f7; border-bottom: 1px solid #e5e7eb; gap: 20px; overflow-x: auto; }
.excel-tabs button { padding: 4px 0 7px; border: 0; border-radius: 0; background: transparent; color: #111827; white-space: nowrap; }
.excel-tabs button.active { font-weight: 700; border-bottom: 3px solid #107c41; }
.excel-tools { min-height: 44px; padding: 6px 8px; background: #f5f6f8; border-bottom: 1px solid #d8dce2; overflow-x: auto; }
.excel-tools select { min-width: 90px; }
.excel-tools select:first-of-type { min-width: 150px; }
.excel-formula-row { padding: 4px 6px; background: #fff; border-bottom: 1px solid #d8dce2; }
.excel-formula-row span:first-child { min-width: 92px; padding: 5px 8px; border: 1px solid #d8dce2; border-radius: 4px; color: #111827; background: #fff; }
.excel-formula-row span:not(:first-child) { color: #64748b; }
.excel-formula-row input { flex: 1; min-height: 29px; border: 1px solid #d8dce2; border-radius: 4px; padding: 5px 10px; color: #111827; background: #fff; outline: 0; }
.excel-quick-actions { padding: 6px 8px; background: #fff; border-bottom: 1px solid #d8dce2; overflow-x: auto; }
.excel-quick-actions .danger, .sheet-delete { color: #b91c1c; border-color: #fecaca; }
.grid-card { border-radius: 0 !important; overflow: hidden !important; margin: 0 -22px -22px !important; background: #fff !important; border: 0 !important; box-shadow: none !important; }
.sheet-wrap { position: relative !important; height: calc(100vh - 235px) !important; min-height: 560px !important; overflow: hidden !important; background: #f3f4f6 !important; }
#luckysheet { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; color: #111827 !important; }
.sheet-tabs { min-height: 36px !important; justify-content: flex-start !important; padding: 0 8px !important; border-top: 1px solid #d8dce2 !important; border-bottom: 0 !important; background: #f8f9fb !important; color: #111827 !important; }
.sheet-nav { color: #64748b; min-width: 70px; font-size: 18px; letter-spacing: 6px; }
.sheet-tab-list { flex: 1; gap: 2px; overflow-x: auto; }
.sheet-tab-list button { min-height: 32px; padding: 6px 14px; border: 0; border-radius: 0; background: transparent; color: #111827; border-bottom: 3px solid transparent; white-space: nowrap; }
.sheet-tab-list button.active { background: #e8f4fb !important; border-bottom-color: #107c41; font-weight: 700; }
.sheet-plus { min-width: 32px; min-height: 28px; padding: 0; border: 0; background: transparent; color: #111827; font-size: 20px; }
.sheet-delete { min-height: 28px; padding: 4px 10px; border-radius: 5px; background: #fff; }
.chart-panel { position: absolute; right: 18px; top: 18px; z-index: 20; width: min(520px, calc(100% - 36px)); height: 310px; padding: 12px; border: 1px solid #d8dce2; border-radius: 10px; background: rgba(255,255,255,.96); box-shadow: 0 16px 45px rgba(15,23,42,.2); }
.chart-panel[hidden] { display: none !important; }
.chart-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: #111827; }
.chart-panel-head button { min-height: 28px; padding: 4px 10px; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; color: #111827; }
.chart-panel canvas { width: 100% !important; height: calc(100% - 38px) !important; }

.sheet-wrap.has-inline-chart { display: grid !important; grid-template-rows: minmax(260px, 34%) minmax(0, 1fr); gap: 10px; padding: 10px; overflow: hidden !important; }
.sheet-wrap.has-inline-chart #luckysheet { position: relative !important; inset: auto !important; width: 100% !important; height: 100% !important; min-height: 0 !important; }
.sheet-wrap.has-inline-chart .fallback-sheet { position: relative; z-index: 1; }
.sheet-wrap.has-inline-chart .chart-panel { position: relative !important; inset: auto !important; right: auto !important; top: auto !important; width: 100% !important; height: 100% !important; margin: 0 !important; z-index: 1 !important; border-radius: 12px; box-shadow: none; background: #fff; }
.sheet-wrap.has-inline-chart .chart-panel canvas { height: calc(100% - 38px) !important; }


/* Template chart/layout refinements */
.chart-panel[data-template="savings"] { right: 34px; top: 28px; width: 360px; height: 300px; border: 0; box-shadow: none; background: rgba(255,255,255,.92); }
.chart-panel[data-template="savings"] .chart-panel-head { display: none; }
.chart-panel[data-template="savings"] canvas { height: 100% !important; }
.chart-panel[data-template="eventoverview"] { width: 460px; height: 280px; }
.chart-panel[data-template="retirement"] { width: min(680px, calc(100% - 36px)); height: 320px; }













/* Inline dashboard chart styled like Excel templates */
.sheet-wrap.has-inline-chart { display: grid !important; grid-template-rows: minmax(440px, 52%) minmax(0, 1fr) !important; gap: 10px !important; padding: 10px !important; overflow: hidden !important; background: #f3f4f6 !important; }
.sheet-wrap.has-inline-chart #luckysheet { position: relative !important; inset: auto !important; width: 100% !important; height: 100% !important; min-height: 0 !important; border: 1px solid #d8e7b8 !important; background: #fff !important; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] { position: relative !important; inset: auto !important; right: auto !important; top: auto !important; width: 100% !important; height: 100% !important; margin: 0 !important; z-index: 1 !important; border-radius: 0 !important; box-shadow: none !important; background: #fff !important; border: 0 !important; display: grid !important; grid-template-columns: minmax(430px, 1fr) minmax(360px, 42%) !important; grid-template-rows: auto minmax(0, 1fr) !important; column-gap: 40px !important; row-gap: 12px !important; padding: 18px 34px 16px 18px !important; overflow: hidden !important; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-panel-head { grid-column: 1 / 2; padding: 0 0 12px 0; border-bottom: 3px solid #7cac12; margin: 0; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-panel-head strong { font-family: Arial, 'Times New Roman', serif; font-size: clamp(25px, 2.15vw, 34px); color: #4b5563; text-transform: uppercase; line-height: 1.12; font-weight: 800; letter-spacing: .01em; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-panel-head button { display: none; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-summary { grid-column: 1 / 2; display: block; color: #4b5563; min-width: 0; overflow: hidden; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] canvas { grid-column: 2 / 3; grid-row: 1 / 3; align-self: center; justify-self: center; width: min(420px, 100%) !important; height: min(340px, 100%) !important; max-height: 340px !important; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] canvas.is-circular-chart { width: min(360px, 100%) !important; height: auto !important; max-width: 360px !important; max-height: 360px !important; aspect-ratio: 1 / 1 !important; }
.chart-kicker, .chart-summary-title { display: none; }
.chart-stat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 200px); align-items: center; min-height: 46px; padding: 9px 13px; border-bottom: 3px solid #fff; background: #96c52b; color: #111827; font-size: 16px; font-weight: 800; }
.chart-stat-row.top-line { background: #48651a; color: #fff; }
.chart-stat-row.soft { background: #d9ecaa; color: #4b5563; }
.chart-stat-row span { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.chart-stat-row b { text-align: right; font-size: 21px; }
.chart-table-title { margin-top: 18px; padding: 8px 4px 5px; border-top: 3px solid #a6cd48; font-family: Arial, 'Times New Roman', serif; color: #4b5563; font-size: 22px; font-weight: 800; text-transform: uppercase; }
.chart-mini-table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 200px); border-top: 3px solid #fff; max-height: none; overflow: hidden; }
.chart-mini-table span, .chart-mini-table b { padding: 8px 10px; border-bottom: 3px solid #fff; background: #d9ecaa; color: #4b5563; min-width: 0; }
.chart-mini-table span { overflow-wrap: anywhere; white-space: normal; }
.chart-mini-table b { text-align: right; background: #eef7d2; }
@media (max-width: 1100px) {
  .sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] { grid-template-columns: 1fr !important; grid-template-rows: auto auto minmax(220px, 1fr) !important; overflow: auto !important; }
  .sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] canvas { grid-column: 1 / 2; grid-row: 3 / 4; width: min(420px, 100%) !important; height: 280px !important; }
  .sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] canvas.is-circular-chart { width: min(340px, calc(100vw - 120px)) !important; height: auto !important; max-width: 340px !important; max-height: 340px !important; aspect-ratio: 1 / 1 !important; }
}

@media (max-width: 700px) {
  .sheet-wrap.has-inline-chart { grid-template-rows: minmax(680px, auto) minmax(260px, 1fr) !important; overflow: auto !important; }
  .sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] { padding: 14px !important; min-width: 0 !important; }
  .sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] canvas.is-circular-chart { width: min(300px, calc(100vw - 110px)) !important; max-width: 300px !important; max-height: 300px !important; }
}

@media (max-width: 850px) {
  .auth-screen { padding: 18px 12px; }
  .auth-card { padding: 22px 18px; }
  .auth-brand { justify-content: flex-start; padding-left: 4px; }
  .account-name { display: none; }
  .account-trigger { padding-right: 6px; }
  .app-shell, .app-shell.sidebar-collapsed, .app-shell:not(.sidebar-collapsed) { width: 100% !important; grid-template-columns: minmax(0, 1fr) !important; }
  .workspace, .app-shell.sidebar-collapsed .workspace { width: 100% !important; min-width: 0 !important; padding-left: 64px !important; padding-right: 12px !important; }
  .grid-card { width: calc(100% + 34px) !important; }
}

/* Unified typography for chart dashboards */
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] {
  --dashboard-font: "Segoe UI", Arial, sans-serif;
  font-family: var(--dashboard-font) !important;
  font-synthesis: none;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-panel-head strong {
  font-family: var(--dashboard-font) !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-summary,
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-stat-row,
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-table-title,
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-mini-table {
  font-family: var(--dashboard-font) !important;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-stat-row {
  font-weight: 700 !important;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-stat-row span,
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-stat-row b {
  font-family: inherit !important;
  font-weight: 700 !important;
  line-height: 1.3;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-stat-row b {
  font-size: 20px !important;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-table-title {
  font-family: var(--dashboard-font) !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-mini-table span,
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-mini-table b {
  font-family: inherit !important;
  font-size: 15px !important;
  line-height: 1.35;
}
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-mini-table span { font-weight: 400 !important; }
.sheet-wrap.has-inline-chart .chart-panel[data-template="dynamic-dashboard"] .chart-mini-table b { font-weight: 700 !important; }

.template-group-title > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.template-group-title > div > small { color: var(--muted); font-size: 12px; font-weight: 700; }
.template-group-footer { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 18px 0 3px; }
.template-group-footer > small { color: var(--muted); font-size: 12px; }
.template-view-all { min-width: 210px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-color: rgba(24,212,255,.38); background: rgba(79,140,255,.16); color: var(--text); font-weight: 800; }
.template-view-all:hover { border-color: var(--cyan); background: rgba(24,212,255,.14); }
.template-view-all span { color: var(--cyan); font-size: 16px; }
@media (max-width: 760px) { .template-group-footer { flex-direction: column; } .template-view-all { width: 100%; } }

.template-group.online-sales {
  border-color: rgba(238, 77, 45, .25);
  background: linear-gradient(180deg, rgba(255, 247, 237, .92), rgba(255, 255, 255, .98));
}
.template-group.online-sales .template-group-title span {
  color: #123f73;
}
.template-group.online-sales .template-group-title span::before {
  content: none;
  margin-right: 0;
}

.template-count { color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }

.excel-tabs .sheet-ai-button {
  position: sticky;
  right: 4px;
  flex: 0 0 auto;
  min-width: 72px;
  min-height: 38px;
  margin: -5px 0 -1px auto;
  padding: 0 18px;
  border: 3px solid #22c55e;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 3px 10px rgba(15,23,42,.24);
  animation: sheet-ai-border-cycle 2.4s linear infinite;
}
.excel-tabs .sheet-ai-button:hover {
  border-color: #06b6d4;
  background: #107c41;
  color: #fff;
  transform: translateY(-1px);
}
.excel-ribbon > .excel-tabs {
  width: 100%;
  flex: 1 1 100%;
}

.excel-right .account-trigger {
  min-height: 32px;
  padding: 2px 8px 2px 3px;
  border-color: #2d3a52;
  background: #111827;
  color: #fff;
}
.excel-right .account-popover button {
  min-height: 36px;
  padding: 7px 10px;
  border-color: #4b2730;
  background: #20151a;
  color: #fecaca;
}
