:root {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-soft: #eaeef6;
  --panel: #ffffff;
  --ink: #131a26;
  --ink-soft: #344054;
  --muted: #687588;
  --line: #e4e8f0;
  --line-strong: #d3dae6;
  --accent: #0f766e;
  --accent-ink: #0b5a53;
  --accent-2: #13a394;
  --accent-soft: #e7f4f2;
  --warm: #f59e0b;
  --danger: #c0362c;
  --danger-soft: #fdecea;
  --terminal: #0d1622;
  --terminal-ink: #d7ffe7;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-md: 0 10px 28px rgba(16, 24, 40, .10);
  --shadow-lg: 0 28px 70px rgba(16, 24, 40, .18);
  --grad-accent: linear-gradient(135deg, #13a394 0%, #0f766e 55%, #0b5a53 100%);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { letter-spacing: -.01em; }

button, input, textarea, select { font: inherit; }

button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 9px 13px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
button:hover { border-color: #b9c2d2; }
button:active { transform: translateY(1px); }
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .25);
  outline-offset: 1px;
}

button.primary {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(15, 118, 110, .28);
}
button.primary:hover { filter: brightness(1.04); border-color: transparent; }
button.primary:disabled { opacity: .7; cursor: progress; }

button.danger { color: var(--danger); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #9aa5b6; }
input:focus, textarea:focus { border-color: var(--accent); }

.muted { color: var(--muted); }

.ic { width: 20px; height: 20px; flex: 0 0 auto; }

/* ============================ AUTH / LOGIN ============================ */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

.auth-aside {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(620px 420px at 90% 8%, rgba(19, 163, 148, .14), transparent 60%),
    radial-gradient(700px 520px at 0% 100%, rgba(245, 158, 11, .1), transparent 55%),
    linear-gradient(165deg, #f1faf8 0%, #e6f4f1 100%);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 5vh 4vw 0;
}
.auth-aside-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.auth-aside-head { flex: 0 0 auto; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.auth-pitch h2 {
  font-size: clamp(25px, 2.7vw, 36px);
  line-height: 1.14;
  margin: 12px 0 14px;
  color: var(--ink);
}
.auth-pitch p {
  margin: 0 0 22px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 44ch;
}
.auth-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 9px; }
.auth-chips li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .75);
  border: 1px solid rgba(15, 118, 110, .14);
  border-radius: 999px;
  padding: 8px 14px 8px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.auth-chips .ic { width: 17px; height: 17px; color: var(--accent); }
.auth-illo {
  margin: auto 0 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex: 1;
  min-height: 0;
}
.auth-illo picture { display: contents; }
.auth-illo img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
  filter: drop-shadow(0 24px 40px rgba(16, 24, 40, .12));
  animation: cardIn .6s cubic-bezier(.2, .8, .2, 1);
}

.auth-main {
  display: grid;
  place-items: center;
  padding: 6vh 24px;
  background: var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 30px;
  box-shadow: var(--shadow-md);
  animation: cardIn .4s cubic-bezier(.2, .8, .2, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } }
.auth-card-head { margin-bottom: 22px; }
.auth-card-head h1 { margin: 14px 0 6px; font-size: 24px; }
.auth-card-head p { margin: 0; }

.brand-logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--grad-accent);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .02em;
  box-shadow: 0 6px 16px rgba(15, 118, 110, .3);
}
.brand-logo.lg { width: 46px; height: 46px; border-radius: 13px; font-size: 17px; }
.brand-text { display: flex; flex-direction: column; font-weight: 700; line-height: 1.05; }
.brand-text small { font-weight: 500; font-size: 11.5px; opacity: .7; letter-spacing: .04em; text-transform: uppercase; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; }
.field-control { position: relative; display: flex; align-items: center; }
.field-control .ic { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.field-control input { padding-left: 40px; }
.field-control input[name="password"] { padding-right: 78px; }
.field-toggle {
  position: absolute;
  right: 6px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 8px;
}
.field-toggle:hover { background: var(--accent-soft); border-radius: 6px; }

.auth-submit { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.auth-submit.loading { position: relative; }
.auth-help { margin: 16px 0 0; text-align: center; font-size: 12.5px; }

/* ============================ APP SHELL ============================ */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: linear-gradient(180deg, #16202c 0%, #131a26 100%);
  color: #e6ebf2;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 14px; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; }
.sidebar .brand-text { color: #fff; }
.sidebar .brand-text small { color: rgba(255, 255, 255, .55); }
.nav-toggle { display: none; background: transparent; border-color: rgba(255, 255, 255, .15); color: #fff; padding: 8px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: rgba(255, 255, 255, .74);
  border: 0;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-size: 14.5px;
}
.nav-item .ic { color: rgba(255, 255, 255, .6); transition: color .15s; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; border-color: transparent; }
.nav-item:hover .ic { color: #fff; }
.nav-item.active {
  background: rgba(19, 163, 148, .18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent-2);
}
.nav-item.active .ic { color: var(--accent-2); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
}
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.sidebar-user-meta { min-width: 0; }
.sidebar-user-meta strong { display: block; font-size: 13.5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta span { display: block; font-size: 12px; color: rgba(255, 255, 255, .58); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 26px;
  background: rgba(243, 245, 250, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title h1 { margin: 0; font-size: 21px; }
.topbar-sub { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.role-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  text-transform: capitalize;
}
.role-badge.role-superadmin, .role-badge.role-admin { background: #fff3df; color: #b76e00; }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; background: #fff; }
.btn-ghost .ic { width: 18px; height: 18px; color: var(--muted); }

.view { padding: 24px 26px 40px; }

/* ============================ DASHBOARD ============================ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row > * { flex: 1; }

.intro-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, .7fr);
  gap: 22px;
  background:
    radial-gradient(700px 320px at 100% 0%, rgba(19, 163, 148, .1), transparent 60%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.intro-copy h2 {
  margin: 0 0 14px;
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.1;
}
.intro-copy p { max-width: 860px; line-height: 1.68; color: var(--ink-soft); margin: 0 0 12px; }
.eyebrow {
  margin: 0 0 10px;
  display: inline-block;
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
}
.intro-steps { display: grid; gap: 12px; align-content: start; }
.intro-steps div {
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f6fcfb, #ffffff);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.intro-steps strong, .intro-steps span { display: block; }
.intro-steps strong { color: var(--accent-ink); font-size: 14.5px; }
.intro-steps span { color: var(--muted); margin-top: 4px; font-size: 13.5px; line-height: 1.45; }

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.tutorial-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.tutorial-card h3 { margin: 0 0 10px; font-size: 16.5px; }
.tutorial-card p, .tutorial-card li { line-height: 1.6; color: var(--ink-soft); }
.tutorial-card ul { margin: 8px 0 0; padding-left: 18px; }
.tutorial-card li { margin: 4px 0; }
.tutorial-card code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 13px;
}
.tutorial-mini {
  border: 1px solid #cfe7e3;
  background: linear-gradient(180deg, #f2fbf9, #ffffff);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}
.tutorial-mini strong, .tutorial-mini span { display: block; }
.tutorial-mini span { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 4px; }

.grid .card h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.grid .card p { margin: 0 0 6px; font-size: 34px; font-weight: 800; color: var(--ink); line-height: 1; }
.grid .card small { line-height: 1.45; display: block; }
.grid .card.action-card { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .12s; }
.grid .card.action-card:hover { border-color: #bfe1dc; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.grid .card .card-cta { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--accent-ink); line-height: 1.3; }

.terminal-guide { border-color: #233042; background: linear-gradient(180deg, #18212e, #131a26); color: #e6edf3; }
.terminal-guide h3 { color: #fff; }
.terminal-guide p { color: #aebccd; }
.terminal-guide code { color: #d7ffe7; background: #0b121b; border-color: #233042; }

/* ============================ TABLES ============================ */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table tr:last-child td, .table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }

/* ============================ TERMINAL ============================ */

.terminal {
  background: var(--terminal);
  color: var(--terminal-ink);
  border: 1px solid #1d2837;
  border-radius: var(--radius);
  padding: 16px;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}
.terminal-output { flex: 1; white-space: pre-wrap; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6; }
.terminal-input { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.terminal-input span { flex: 0 0 auto; color: var(--accent-2); }
.terminal-input input { background: #0a1019; border-color: #1d2837; color: var(--terminal-ink); }

textarea { min-height: 90px; resize: vertical; }
.card textarea { margin-bottom: 10px; }

.error { color: var(--danger); margin: 0 0 12px; background: var(--danger-soft); border: 1px solid #f3c6c1; border-radius: var(--radius-xs); padding: 10px 12px; font-size: 13.5px; }
.error[hidden] { display: none; }
.success { color: var(--accent); margin: 8px 0; }

/* ============================ FILE EXPLORER ============================ */

.drive-shell-ai {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 620px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.drive-side-ai { border-right: 1px solid var(--line); background: #f8fafc; padding: 16px; }
.drive-main-action { width: 100%; margin-bottom: 10px; text-align: center; }
.drive-stat { margin: 18px 0 10px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.drive-stat strong { display: block; font-size: 24px; }
.drive-stat span, .drive-help span, .drive-stat-grid span { display: block; color: var(--muted); font-size: 13px; }
.drive-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drive-stat-grid div, .drive-help { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.drive-help { margin-top: 10px; line-height: 1.45; }
.drive-main-ai { padding: 16px; min-width: 0; }
.drive-toolbar-ai { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.breadcrumbs-ai { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.breadcrumbs-ai button { padding: 6px 10px; background: var(--accent-soft); border-color: #cfe7e3; color: var(--accent-ink); }
.breadcrumbs-ai span { color: var(--muted); }
.toolbar-actions-ai { display: flex; align-items: center; gap: 8px; }
.toolbar-actions-ai input { width: 230px; }

.dropzone-ai {
  border: 1.5px dashed #89bdb7;
  background: linear-gradient(180deg, #f2fbf9, #ffffff);
  border-radius: var(--radius-sm);
  min-height: 116px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.dropzone-ai strong { display: block; font-size: 18px; }
.dropzone-ai span, .dropzone-ai small { color: var(--muted); }
.dropzone-ai.is-drag { background: #e2f7f3; border-color: var(--accent); }

.file-grid-ai { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.file-card-ai { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; padding: 10px; cursor: pointer; min-width: 0; transition: border-color .15s, box-shadow .15s, transform .12s; }
.file-card-ai:hover { border-color: #9bb8c0; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.file-card-ai.selected { outline: 2px solid var(--accent); border-color: var(--accent); }
.select-dot-ai { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: #fff; z-index: 2; }
.file-card-ai.selected .select-dot-ai { background: var(--accent); color: #fff; border-color: var(--accent); }
.file-preview-ai { height: 108px; border-radius: var(--radius-xs); display: grid; place-items: center; background: #eef2f7; color: #475467; font-weight: 800; }
.folder-preview-ai { background: linear-gradient(135deg, #fee7a5, #f2b84b); color: #7a4a00; font-size: 48px; }
.file-preview-ai.pdf { background: #fff1f0; color: #b42318; }
.file-preview-ai.image { background: #ecfdf3; color: #067647; }
.file-preview-ai.excel { background: #e9f8ef; color: #087443; }
.file-preview-ai.audio { background: #eef4ff; color: #175cd3; }
.file-preview-ai.video { background: #f4f3ff; color: #5925dc; }
.file-card-meta-ai { margin-top: 9px; min-width: 0; }
.file-card-meta-ai strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card-meta-ai small { color: var(--muted); }
.file-actions-ai { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.file-actions-ai button, .file-actions-ai a { flex: 1 1 auto; min-width: 72px; text-align: center; text-decoration: none; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 8px; border-radius: 6px; font-size: 13px; }
.file-actions-ai .danger { color: var(--danger); }

.empty-state-ai { text-align: center; padding: 34px; color: var(--muted); }
.empty-state-ai strong { display: block; color: var(--ink); margin-bottom: 4px; }

.bulk-bar-ai { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 10px; background: #101828; color: #fff; border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: var(--shadow-lg); }
.bulk-bar-ai[hidden] { display: none; }
.bulk-bar-ai button { background: #fff; }

.modal-backdrop-ai { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.modal-backdrop-ai[hidden] { display: none; }
.modal-ai { width: min(420px, calc(100% - 28px)); background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-lg); animation: cardIn .25s ease; }
.modal-ai h3 { margin: 0 0 6px; }
.modal-ai p { margin: 0 0 12px; color: var(--muted); }
.modal-actions-ai { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ============================ CHAT / CONSOLE IA ============================ */

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 170px);
  min-height: 540px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f6fcfb, #ffffff);
}
.bot-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 22px;
  box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(15, 118, 110, .18);
}
.chat-head-meta { flex: 1; min-width: 0; }
.chat-head-meta strong { display: block; font-size: 15px; }
.chat-head-meta span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.chat-head .btn-ghost { flex: 0 0 auto; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(600px 300px at 50% -5%, rgba(19, 163, 148, .05), transparent 70%),
    #f7f9fc;
  scroll-behavior: smooth;
}

.bubble { display: flex; gap: 10px; max-width: 80%; align-items: flex-end; animation: bubbleIn .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px); } }
.bubble-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 16px;
}
.bubble-body {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  padding: 11px 15px;
  line-height: 1.55;
  font-size: 14.5px;
  color: var(--ink);
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.bubble-body p { margin: 0 0 8px; }
.bubble-body p:last-child { margin: 0; }
.bubble-body .muted { font-size: 13px; }

.bubble.me { margin-left: auto; flex-direction: row-reverse; }
.bubble.me .bubble-body {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}
.bubble.welcome { max-width: 92%; }
.bubble.warn .bubble-body { background: #fff8ed; border-color: #f3d9a6; color: #8a5a00; }

.bubble.files { max-width: 100%; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.file-chip {
  background: var(--accent-soft);
  border: 1px solid #cfe7e3;
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
}

.typing { display: inline-flex; gap: 4px; padding: 2px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .4; animation: typing 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.bubble.live .bubble-body { background: #f6fcfb; border-color: #cfe7e3; }
.live-line { display: flex; align-items: center; gap: 9px; }
.live-spin {
  flex: 0 0 auto;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #cfe7e3;
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.live-text {
  font-size: 13.5px;
  color: var(--ink-soft);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 56ch;
  animation: liveShimmer 1.8s ease-in-out infinite;
}
@keyframes liveShimmer { 0%, 100% { opacity: .7; } 50% { opacity: 1; } }

.image-msg { max-width: 70%; }
.image-msg .img-card {
  margin: 0;
  max-width: 260px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  transition: box-shadow .15s, transform .12s;
}
.image-msg .img-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.image-msg .img-card img { display: block; width: 100%; max-height: 280px; object-fit: cover; }
.image-msg .img-card figcaption { font-size: 11.5px; color: var(--muted); padding: 7px 11px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 12, 20, .92);
  display: flex;
  flex-direction: column;
  padding: 20px;
  animation: cardIn .2s ease;
}
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff; margin-bottom: 14px; }
.lightbox-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.lb-btn { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); color: #fff; padding: 9px 14px; border-radius: 9px; text-decoration: none; font-size: 13.5px; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, .22); }
.lightbox-img { flex: 1; min-height: 0; max-width: 100%; object-fit: contain; border-radius: 10px; }

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.composer-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  padding: 0;
}
.composer-btn.attach { background: var(--accent-soft); border-color: #cfe7e3; }
.composer-btn.attach:hover { background: #d8efeb; }
.composer-btn.mic { background: #fff; }
.composer-btn.mic:hover { background: var(--accent-soft); border-color: #cfe7e3; }
.composer-btn.mic.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: micPulse 1.2s infinite;
}
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 54, 44, .45); }
  70% { box-shadow: 0 0 0 10px rgba(192, 54, 44, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 54, 44, 0); }
}
.composer-btn.send {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(15, 118, 110, .28);
}
.composer-btn.send:hover { filter: brightness(1.05); }
.chat-composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  border-radius: 12px;
  padding: 11px 14px;
  line-height: 1.4;
}

.chat-foot { margin: 0; padding: 9px 16px; text-align: center; font-size: 12px; color: var(--muted); background: #fff; border-top: 1px solid var(--line); }
.chat-foot code { background: var(--bg-soft); border-radius: 5px; padding: 1px 6px; color: var(--accent-ink); }

.chat-drop {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  text-align: center;
  padding: 24px;
  background: rgba(231, 244, 242, .92);
  border: 3px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 600;
}
.chat-drop.show { display: grid; }
.chat-drop-ic { display: block; font-size: 40px; margin-bottom: 8px; }

/* ============================ SHARED PAGE COMPONENTS ============================ */

.page-intro {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background:
    radial-gradient(420px 200px at 100% 0%, rgba(19, 163, 148, .09), transparent 65%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.page-intro-ic {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent-soft);
  font-size: 24px;
}
.page-intro h2 { margin: 0 0 5px; font-size: 19px; }
.page-intro p { margin: 0; color: var(--ink-soft); line-height: 1.55; max-width: 80ch; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill-ok { background: #e7f6ee; color: #0a7c43; }
.pill-run { background: #e8f1ff; color: #1559c4; }
.pill-wait { background: #fff4e1; color: #a96a00; }
.pill-bad { background: var(--danger-soft); color: #b42318; }
.pill-mute { background: #eef1f6; color: #5b6677; }

.progress { height: 8px; width: 100%; max-width: 180px; background: #eaeef4; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--grad-accent); transition: width .3s; }

.data-table thead th {
  background: #f7f9fc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  font-weight: 700;
}
.data-table td { vertical-align: middle; }
.data-table .cell-action { text-align: right; width: 1%; white-space: nowrap; }

.form-card { margin-bottom: 18px; }
.form-card .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 8px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cap-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.cap-card:hover { border-color: #bfe1dc; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cap-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cap-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); font-size: 20px; }
.cap-card strong { font-size: 15px; }
.cap-risk { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }

.empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 4px;
  padding: 48px 24px;
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-ic { font-size: 40px; margin-bottom: 6px; }
.empty strong { color: var(--ink); font-size: 16px; }
.empty span { max-width: 44ch; line-height: 1.5; }

.log-card { margin-top: 16px; }
.log-card h3 { margin: 0 0 12px; font-size: 15px; }
.log-line { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; }
.log-line:first-of-type { border-top: 0; }
.log-level {
  flex: 0 0 auto;
  min-width: 64px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
}
.log-info .log-level { color: #1559c4; }
.log-error .log-level { color: #b42318; }
.log-warn .log-level, .log-warning .log-level { color: #a96a00; }
.log-success .log-level { color: #0a7c43; }

/* ============================ FILE THUMBNAILS + TOAST ============================ */

.file-preview-ai.thumb { position: relative; overflow: hidden; background: #eef2f7; }
.file-preview-ai.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.file-actions-ai .copy-path {
  flex: 1 1 100%;
  background: var(--accent-soft);
  border-color: #cfe7e3;
  color: var(--accent-ink);
  font-weight: 600;
}
.file-actions-ai .copy-path:hover { background: #d8efeb; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(10px);
  z-index: 60;
  background: #101828;
  color: #fff;
  padding: 11px 17px;
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================ RESPONSIVE ============================ */

@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 30; }
  .sidebar-top { padding-bottom: 8px; }
  .nav-toggle { display: inline-flex; }
  .nav { display: none; }
  .sidebar.open .nav { display: flex; }
  .sidebar-user { display: none; }
  .sidebar.open .sidebar-user { display: flex; margin-top: 8px; }
  .topbar { padding: 14px 16px; }
  .topbar-sub { display: none; }
  .btn-ghost span { display: none; }
  .view { padding: 18px 16px 32px; }
  .intro-panel { grid-template-columns: 1fr; padding: 20px; }
  .drive-shell-ai { grid-template-columns: 1fr; }
  .drive-side-ai { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat { height: calc(100vh - 150px); min-height: 460px; }
  .bubble { max-width: 92%; }
  .chat-head-meta span { display: none; }
  .drive-toolbar-ai { align-items: stretch; flex-direction: column; }
  .toolbar-actions-ai { flex-direction: column; align-items: stretch; }
  .toolbar-actions-ai input { width: 100%; }
}
