:root{
  --bg:#f9fafb;
  --card:#ffffff;
  --txt:#111827;
  --accent:#6b7280;
  --muted:#d1d5db;
  --tooltip-bg:#1f2937;
  --danger:#b91c1c;
  --deleted:#9ca3af;
  --ins-bg: rgba(34,197,94,0.16);
  --del-bg: rgba(239,68,68,0.14);
  --ins-txt:#166534;
  --del-txt:#991b1b;
  --panel:#ffffff;
  --border:#e5e7eb;
}

[data-theme="dark"]{
  --bg:#111827;
  --card:#1f2937;
  --txt:#e5e7eb;
  --accent:#9ca3af;
  --muted:#4b5563;
  --tooltip-bg:#374151;
  --danger:#ef4444;
  --deleted:#6b7280;
  --ins-bg:rgba(34,197,94,0.20);
  --del-bg:rgba(239,68,68,0.18);
  --ins-txt:#86efac;
  --del-txt:#fca5a5;
  --panel:#1f2937;
  --border:#374151;
}

body{
  font-family:Arial,Helvetica,sans-serif;
  margin:0;
  padding:2rem;
  background:var(--bg);
  color:var(--txt);
  position:relative;
}

h1{
  margin:0 0 1rem 0;
  font-size:2rem;
  text-align:center;
}

/* Title itself has no margins now (wrapper controls spacing) */
h2{
  font-size:1.5rem;
  margin:0;
  text-align:center;
  color:var(--accent);
  cursor:pointer;
}

/* Put top buttons in a single fixed container */
.top-actions{
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  z-index: 11000;
  display: flex;
  gap: 8px;
}

/* Override per-button fixed positioning ONLY inside the container */
.top-actions .download-top-btn{
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
}

.download-top-btn{
  position:fixed;
  top:1rem;
  right:1.5rem;
  background:var(--accent);
  color:#fff;
  border:none;
  padding:.4rem .9rem;
  border-radius:999px;
  cursor:pointer;
  font-size:.85rem;
  z-index:11000;
}

/* Top bar layout */
.top-bar{
  max-width:1100px;
  margin:0 auto 1.5rem auto;
  display:flex;
  flex-direction:column;
  gap:.75rem;
  align-items:stretch;
  justify-content:center;
  font-size:.95rem;
  text-align:left;
}

/* Module row (selector) */
.module-row{
  display:flex;
  gap:.5rem;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  width:min(900px, 100%);
  margin:0 auto;
}

.module-selector-wrapper{
  display:flex;
  align-items:center;
  justify-content:flex-start;
}

.module-selector-wrapper select{
  padding:.7rem 1.4rem;
  border-radius:999px;
  border:1px solid var(--muted);
  font-size:1.05rem;
  background:var(--card);
  color:var(--txt);
  cursor:pointer;
  width:520px;
  text-align-last:center;
}

.module-controls-inline{
  display:flex;
  gap:.5rem;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:wrap;
}

.module-controls-inline button{
  background:var(--accent);
  color:#fff;
  border:none;
  padding:.4rem .9rem;
  border-radius:999px;
  cursor:pointer;
  font-size:.85rem;
}

.module-controls-inline button.danger-btn{
  background:var(--danger);
  color:#fff;
}

/* Model/version controls */
.version-controls{
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
  align-items:center;
  justify-content:center;
  font-size:.9rem;
  width:min(900px, 100%);
  margin:0 auto;
}

.model-version-group{
  display:flex;
  width:520px;
  gap:.25rem;
}

.model-version-group input,
.model-version-group select{
  flex:1;
  min-width:0;
  padding:.7rem 1.2rem;
  border-radius:999px;
  border:1px solid var(--muted);
  font-size:1.05rem;
  background:var(--card);
  color:var(--txt);
}

.version-buttons{
  display:flex;
  gap:.5rem;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:wrap;
}

.version-buttons button{
  background:var(--accent);
  color:#fff;
  border:none;
  padding:.35rem .8rem;
  border-radius:999px;
  cursor:pointer;
  font-size:.85rem;
}

/* Toggles */
.toggle-row{
  display:flex;
  gap:.75rem;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
}

.group-toggle{
  font-size:.85rem;
  color:var(--accent);
  display:flex;
  align-items:center;
  gap:.25rem;
}

.group-toggle input{ margin:0; }

/* Default button */
button{
  background:var(--accent);
  color:#fff;
  border:none;
  padding:.4rem .9rem;
  border-radius:4px;
  cursor:pointer;
}

button.secondary{ background:var(--muted); color:var(--txt); }
button[disabled]{ opacity:0.4; cursor:not-allowed; }

/* Card */
.card{
  background:var(--card);
  border-radius:12px;
  box-shadow:0 4px 12px rgba(0,0,0,.06);
  padding:1.25rem 1.5rem 1.5rem;
  margin-bottom:2rem;
  position:relative;
}

/* ===========================
   Module title + delete icon
   =========================== */
.module-title-wrap{
  position: relative;
  width: min(900px, 100%);
  margin: 2rem auto 1rem auto;
}

/* delete icon on right, hidden unless hover */
.module-title-wrap #deleteModuleBtn{
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);

  opacity: 0;
  pointer-events: none;

  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .25rem .55rem;
  font-size: 1rem;
  line-height: 1;

  transition: opacity .15s ease;
}

.module-title-wrap:hover #deleteModuleBtn,
.module-title-wrap:focus-within #deleteModuleBtn{
  opacity: 1;
  pointer-events: auto;
}

/* Group header */
.group-header{
  margin-bottom:.5rem;
  position:sticky;
  top:0;
  z-index:2;
  background:var(--card);
  padding-top:.25rem;
}

.group-header::after{
  content:"";
  display:block;
  height:1px;
  background:var(--border);
  margin-top:.25rem;
}

.group-header-line{
  display:flex;
  flex-wrap:wrap;
  gap:.25rem;
  align-items:baseline;
  font-size:1.2rem;
}

.group-header-line .group-sub{ font-weight:700; cursor:pointer; }
.group-header-line .group-clause{ font-weight:600; cursor:pointer; color:var(--txt); }

.group-row{ padding-top:.75rem; margin-top:.5rem; }
.group-row:first-of-type{ padding-top:0; margin-top:.25rem; }

.group-row.overlay-row{ border-left:3px solid var(--danger); padding-left:1rem; margin-left:-1rem; }
.group-row.deleted-row{ opacity:0.75; border-left:3px solid var(--deleted); padding-left:1rem; margin-left:-1rem; }
.group-row.deleted-row .row-number{ background:var(--bg); color:var(--deleted); }

.row-number{
  font-size:.75rem;
  background:var(--border);
  border-radius:999px;
  padding:.1rem .6rem;
  color:var(--txt);
  white-space:nowrap;
  cursor:pointer;
}

.row-number.overlay-active{ background:#c7d2fe; color:#1e3a8a; }
.row-number.deleted-active{ background:var(--border); color:var(--deleted); }

.row-number .t-dot{
  display:inline-block;
  width:8px;
  height:8px;
  border-radius:50%;
  margin-left:4px;
  vertical-align:middle;
  padding:4px;
  margin-top:-4px;
  margin-bottom:-4px;
  margin-right:-4px;
  cursor:help;
  background-clip:content-box;
}
.t-dot-red{ background-color:#ef4444; }
.t-dot-orange{ background-color:#f97316; }
.t-dot-blue{ background-color:#3b82f6; }
.t-dot-green{ background-color:#22c55e; }
.t-dot-darkgreen{ background-color:#15803d; }

.translation-changed{
  outline:2px solid #f97316;
  outline-offset:2px;
  border-radius:4px;
}

/* --- Translation To Do Side Panel --- */
#mainArea{ display:flex; gap:1rem; }
#container{ flex:1; min-width:0; }
#todoPanelWrap{
  width:200px;
  flex-shrink:0;
  align-self:flex-start;
  position:sticky;
  top:10px;
  max-height:calc(100vh - 20px);
  overflow-y:auto;
  background:var(--card);
  border:1px solid #e5e7eb;
  border-radius:8px;
  font-size:.72rem;
  display:none;
}
#todoPanelWrap .todo-header{
  position:sticky;
  top:0;
  z-index:1;
  background:var(--card);
  padding:8px 10px;
  font-weight:bold;
  font-size:.9rem;
  border-bottom:1px solid #e5e7eb;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
#todoPanelWrap .todo-header button{
  background:none;border:none;cursor:pointer;font-size:16px;color:var(--txt);
}
#todoPanelWrap .todo-footer{
  position:sticky;
  bottom:0;
  background:var(--card);
  padding:6px 10px;
  font-size:.8rem;
  color:#6b7280;
  border-top:1px solid #e5e7eb;
}
#todoPanelWrap table{ width:100%; border-collapse:collapse; }
#todoPanelWrap .todo-mod-hdr td{
  padding:8px 10px 4px;
  font-weight:bold;
  font-size:.85rem;
  max-width:180px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#todoPanelWrap .todo-row td{ padding:2px 2px; vertical-align:top; }
#todoPanelWrap .todo-row td:first-child{ width:10px; padding:2px 0 2px 6px; }
#todoPanelWrap .todo-row td:nth-child(2){ padding:2px 0; }
#todoPanelWrap .todo-row td:nth-child(3){ padding:2px 4px 2px 2px; }
#todoPanelWrap .todo-dot{
  display:inline-block;width:8px;height:8px;border-radius:50%;vertical-align:middle;
}
#todoPanelWrap .todo-field{
  cursor:pointer;
  color:#2563eb;
  text-decoration:underline;
  text-decoration-color:transparent;
  transition:text-decoration-color .15s;
}
#todoPanelWrap .todo-field:hover{
  text-decoration-color:#2563eb;
}

/* ===========================
   Row actions hover-only
   =========================== */
.row-actions{
  display:flex;
  flex-wrap:wrap;
  gap:.25rem;
  position:absolute;
  right:0;
  top:0;
  z-index:2;
  background:var(--card);
  padding-left:.5rem;

  opacity:0;
  pointer-events:none;
  transform: translateY(-2px);
  transition: opacity .12s ease, transform .12s ease;
}

.group-row:hover .row-actions,
.group-row:focus-within .row-actions{
  opacity:1;
  pointer-events:auto;
  transform:none;
}

.row-actions button{
  background:var(--muted);
  color:var(--txt);
  padding:.25rem .55rem;
  border-radius:6px;
  cursor:pointer;
  font-size:.85rem;
  line-height:1.1;
}

.row-actions button.danger{ background:var(--danger); color:#fff; }
.row-actions button.undo{ background:#e0e7ff; color:#1e3a8a; }

.expected-row{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:.5rem;
  margin:.25rem 0 .75rem 0;
  position:relative;
}

.expected-main{
  display:flex;
  align-items:flex-start;
  gap:.5rem;
  flex:1;
  min-width:0;
}

.expected{
  font-style:italic;
  white-space:pre-line;
  cursor:pointer;
  font-size:.95rem;
  font-weight:500;
  color:var(--accent);
}

/* Levels grid */
.levels{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:1rem;
  margin-top:.5rem;
  padding:0;
  list-style:none;
}

.level-cell{
  white-space:pre-line;
  line-height:1.4;
  border-left:2px solid var(--accent);
  padding-left:.75rem;
  border-radius:4px;
  min-height:3rem;
  cursor:pointer;
}

.level-cell > strong:first-child{ display:block; margin-bottom:.25rem; }
.level-cell.empty{ border-color:var(--muted); color:var(--muted); }

/* Notes */
.notes-row{
  margin-top:.5rem;
  font-size:.85rem;
  color:var(--accent);
  cursor:pointer;
  padding-left:.25rem;
  border-left:2px dashed var(--border);
}

.notes-row strong{ font-weight:600; margin-right:.25rem; }
.notes-row.empty{ font-style:italic; color:#9ca3af; }

/* Remove default margins on Quill block tags in rendered areas */
.level-cell p, .level-cell ul, .level-cell ol,
.expected p, .expected ul, .expected ol,
.group-header-line p, .group-header-line ul, .group-header-line ol,
.notes-row p, .notes-row ul, .notes-row ol{
  margin:0;
  padding:0;
}

/* Proper list styling & indenting in content areas */
.level-cell ul, .expected ul, .group-header-line ul, .notes-row ul{
  list-style-type:disc;
  margin-left:1.25rem;
  padding-left:1rem;
}

.level-cell ol, .expected ol, .group-header-line ol, .notes-row ol{
  list-style-type:decimal;
  margin-left:1.25rem;
  padding-left:1rem;
}

/* Info (tooltips) */
.info{
  margin:.35rem 0 0 0;
  border-bottom:1px dotted var(--accent);
  cursor:help;
  width:fit-content;
  padding:0 1px;
  border-radius:3px;
}

.info-label{ display:inline; }
.info.pinned{ outline:2px solid rgba(99,102,241,0.35); outline-offset:2px; }

/* Tooltip floating */
.floating-tooltip{
  position:fixed;
  z-index:20000;
  background:var(--tooltip-bg);
  color:#fff;
  padding:.6rem .8rem;
  border-radius:8px;
  font-size:.85rem;
  line-height:1.35;
  min-width:260px;
  max-width:520px;
  box-shadow:0 10px 24px rgba(0,0,0,.35);
}

.floating-tooltip .tip-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
  margin-bottom:.35rem;
  padding-bottom:.35rem;
  border-bottom:1px solid rgba(255,255,255,.14);
}

.floating-tooltip .tip-title{
  font-weight:700;
  font-size:.9rem;
  margin:0;
}

.floating-tooltip .tip-actions{
  display:flex;
  gap:.35rem;
  align-items:center;
}

.floating-tooltip .tip-actions button{
  background:rgba(255,255,255,.12);
  color:#fff;
  border:none;
  padding:.2rem .45rem;
  border-radius:6px;
  cursor:pointer;
  font-size:.75rem;
}

.floating-tooltip .tip-body p,
.floating-tooltip .tip-body ul,
.floating-tooltip .tip-body ol{
  margin:.35rem 0 0 0;
  padding:0;
}

.floating-tooltip .tip-body ul{
  list-style-type:disc;
  margin-left:1.25rem;
  padding-left:1rem;
}

.floating-tooltip .tip-body ol{
  list-style-type:decimal;
  margin-left:1.25rem;
  padding-left:1rem;
}

/* Hover highlight on editable fields */
[data-path]{
  position:relative;
  border-radius:4px;
  transition:background-color .15s ease;
}

[data-path]:hover{ background-color:var(--border); }

/* Modal (unified styling) */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:10000;
}

.modal.hidden{ display:none; }

.modal-content{
  background:var(--card);
  padding:0;
  border-radius:14px;
  max-width:900px;
  width:95%;
  height:80vh;
  max-height:80vh;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
  position:relative;
  z-index:10001;
  font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  overflow:hidden;
}

.modal-content.history-modal{
  height:auto;
  max-height:80vh;
}

/* New-model modal: auto height */
.modal-content.new-model-modal{
  height:auto;
  max-height:80vh;
  max-width:520px;
}

/* Modal header */
.modal-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  gap:10px;
}

.modal-header h3{
  margin:0;
  font-size:1.15rem;
  font-weight:900;
}

.modal-close{
  appearance:none;
  border:none;
  background:transparent;
  font-size:18px;
  line-height:1;
  cursor:pointer;
  padding:6px 8px;
  border-radius:10px;
}
.modal-close:hover{ background:rgba(0,0,0,.06); }

/* Modal body */
.modal-body{
  padding:14px 16px;
}

/* History keeps its own scrolling */
#historyModal .modal-body{
  flex:1;
  overflow:auto;
  min-height:0;
}

/* Editor: prevent double scrollbars (modal + quill); no side padding for full-width Quill */
#editorModal .modal-body{
  flex:1;
  overflow:hidden;
  min-height:0;
  padding:0 16px;
}

/* Footer (unified) */
.modal-footer{
  display:flex;
  justify-content:flex-end;
  padding:12px 16px;
  border-top:1px solid var(--border);
  gap:10px;
  flex-wrap:wrap;
}

/* Unified modal buttons — override generic button styles inside modals */
.modal-footer button,
.aimm-modal-btn{
  padding:10px 14px;
  border-radius:12px;
  border:1px solid #6b7280;
  background:#6b7280;
  color:#fff;
  font-weight:900;
  font-size:.9rem;
  cursor:pointer;
  white-space:nowrap;
}
.modal-footer button:hover,
.aimm-modal-btn:hover{ background:#555e6b; }
.modal-footer button:active,
.aimm-modal-btn:active{ transform:translateY(1px); }

.modal-footer button.secondary,
.aimm-modal-btn.secondary{
  background:var(--card);
  color:var(--txt);
  border-color:var(--border);
}

.modal-footer button[disabled]{
  opacity:0.4;
  cursor:not-allowed;
}

/* New-model form */
.new-model-form{
  display:flex;
  flex-direction:column;
  gap:.75rem;
}
.new-model-field{
  display:flex;
  flex-direction:column;
  gap:.3rem;
}
.new-model-label{
  font-size:.85rem;
  font-weight:850;
  color:var(--txt);
  opacity:.9;
}
.new-model-hint{ opacity:.7; }
.new-model-form input[type="text"]{
  width:100%;
  box-sizing:border-box;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--muted);
  font-size:1rem;
  font-weight:800;
  outline:none;
  background:var(--card);
  color:var(--txt);
}
.new-model-form input[type="text"]:focus{ border-color:var(--txt); }
.new-model-checkbox-row{
  display:flex;
  align-items:center;
  gap:.5rem;
  font-size:.9rem;
  margin-top:4px;
}

/* ===========================
   History styles (RESTORED)
   =========================== */
.history-meta{
  font-size:.85rem;
  color:var(--accent);
  margin-bottom:.5rem;
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
  align-items:center;
  justify-content:space-between;
}

.history-entry{
  border:1px solid var(--border);
  border-radius:8px;
  padding:.75rem;
  margin-bottom:.5rem;
  background:var(--bg);
}

.history-entry.current{
  border-color:var(--danger);
  background:#fef2f2;
  box-shadow:0 0 0 1px #fecaca;
}

.history-entry h4{
  margin:.1rem 0 .5rem;
  font-size:.9rem;
  color:var(--txt);
}

.history-field{
  font-size:.85rem;
  margin-bottom:.35rem;
}

.history-field strong{ font-weight:600; }

/* Redline diff */
.diff{
  display:inline;
  white-space:pre-wrap;
  word-break:break-word;
}

.diff del{
  background:var(--del-bg);
  color:var(--del-txt);
  text-decoration:line-through;
  padding:0 .1rem;
  border-radius:3px;
}

.diff ins{
  background:var(--ins-bg);
  color:var(--ins-txt);
  text-decoration:none;
  padding:0 .1rem;
  border-radius:3px;
}

/* ===========================
   Translation split + Quill sizing (FIXED)
   =========================== */

#editorModal .modal-content{
  display:flex;
  flex-direction:column;
}

#editorModal .modal-body{
  flex:1;
  min-height:0;
  overflow:hidden;
}

.editor-split{
  height:100%;
  min-height:0;
  display:flex;
  gap:1rem;
}

.editor-pane{
  flex:1;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  border:1px solid var(--border);
  border-radius:8px;
  overflow:hidden;
}

.editor-pane-head{
  padding:.35rem .5rem;
  background:var(--bg);
  border-bottom:1px solid var(--border);
  font-size:.85rem;
  color:var(--accent);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.5rem;
}

.editor-pane-title{ font-weight:700; }

.editor-pane-body{
  flex:1;
  min-height:0;
  overflow:hidden;

  /* Quill inserts .ql-toolbar + .ql-container as siblings here */
  display:flex;
  flex-direction:column;
}

/* Hidden by default; shown when toggle is on */
#translationPane{ display:none; }
#editorModal.show-translation #translationPane{ display:flex; }

/* History panes: hidden by default */
#prevEnglishPane,
#prevTranslationPane{ display:none; }
#editorModal.show-history #prevEnglishPane,
#editorModal.show-history #prevTranslationPane{ display:flex; }

/* Widen modal for 4-column history view */
#editorModal.show-history .modal-content{ max-width:1600px; }

/* Read-only pane styling */
.editor-pane-readonly{ background:var(--bg); }
.editor-pane-readonly .editor-pane-head{ background:var(--border); }

/* Disabled Quill in translation mode matches read-only styling */
#editorModal.show-translation #englishPane .ql-toolbar{ display:none; }
#editorModal.show-translation #englishPane .ql-container{ border-top:1px solid var(--border,#ccc); }
#editorModal.show-translation #englishPane .editor-pane-head{ background:var(--border); }

.readonly-content{
  flex:1;
  overflow:auto;
  padding:12px 15px;
  font-size:1.1rem;
  line-height:1.6;
  font-family:inherit;
  user-select:text;
}

#quillEditor,
#quillEditorLang{
  flex:1;
  min-height:0;
}

/* Toolbar natural height, container fills remainder */
.editor-pane-body .ql-toolbar{
  flex:0 0 auto;
}

.editor-pane-body .ql-container{
  flex:1 1 auto;
  min-height:0;
  height:auto !important;
}

.editor-pane-body .ql-editor{
  height:100%;
  overflow:auto;
  font-size:1.1rem;
  line-height:1.6;
}

/* Footer: bottom-left Translate + bottom-right Save/Cancel */
#editorModal .modal-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-top:.5rem;
  gap:.75rem;
  flex-wrap:wrap;
}

/* Editor modal footer needs space-between for translate + buttons layout */
#editorModal .modal-footer{
  justify-content:space-between;
}

.modal-footer-left{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:.5rem;
}

.modal-footer-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:.5rem;
  flex-wrap:wrap;
}

.translate-control{
  display:flex;
  align-items:center;
  gap:.5rem;
  color:var(--accent);
  font-size:.9rem;
}

.translate-control select{
  padding:.25rem .7rem;
  border-radius:999px;
  border:1px solid var(--muted);
  background:var(--card);
  font-size:.9rem;
  color:var(--txt);
}

/* Stack panes on small screens when translation is visible */
@media (max-width:900px){
  #editorModal.show-translation .editor-split{
    flex-direction:column;
  }
}

/* Wrap 4-column layout into 2x2 grid on medium screens */
@media (max-width:1200px){
  #editorModal.show-history .editor-split{
    flex-wrap:wrap;
  }
  #editorModal.show-history .editor-pane{
    flex:1 1 45%;
    min-height:200px;
  }
}

@media (max-width:1000px){
  .levels{ grid-template-columns:1fr; }
}

/* === AI Translation === */
.ai-suggest-btn{
  padding:.2rem .6rem;
  border-radius:8px;
  border:1px solid #6366f1;
  background:#6366f1;
  color:#fff;
  font-weight:700;
  font-size:.78rem;
  cursor:pointer;
  white-space:nowrap;
  transition:opacity .15s, background .15s;
  line-height:1.4;
}
.ai-suggest-btn:hover{ background:#4f46e5; }
.ai-suggest-btn:disabled{ opacity:0.5; cursor:not-allowed; }

.ai-why-btn{
  padding:.2rem .5rem;
  border-radius:8px;
  border:1px solid var(--muted);
  background:var(--bg);
  color:var(--accent);
  font-weight:600;
  font-size:.72rem;
  cursor:pointer;
  white-space:nowrap;
  transition:background .15s, color .15s;
  line-height:1.4;
}
.ai-why-btn:hover{ background:var(--border); color:var(--txt); }

.ai-batch-progress{
  width:100%;
  height:6px;
  background:var(--border);
  border-radius:999px;
  overflow:hidden;
  margin:12px 0;
}
.ai-batch-progress-bar{
  height:100%;
  background:#6366f1;
  border-radius:999px;
  transition:width .3s ease;
  width:0%;
}
.ai-batch-row-list{
  max-height:300px;
  overflow-y:auto;
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px;
  margin-top:8px;
}
.ai-batch-row-item{
  padding:6px 8px;
  border-bottom:1px solid var(--bg);
  font-size:.85rem;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}
.ai-batch-row-item:last-child{ border-bottom:none; }

/* === Translate Mirror === */
.mirror-row{
  background:var(--bg);
  border-left:3px solid var(--accent);
  padding-left:1rem;
  margin-left:-1rem;
  opacity:0.7;
}
.mirror-row .row-number{
  background:var(--accent);
  color:var(--card);
  font-size:.7rem;
  padding:.1rem .5rem;
  border-radius:4px;
}
.mirror-row .row-actions{ display:none !important; }

/* Approve button in mirror mode */
.row-actions button.approve{
  background:#22c55e;
  color:#fff;
  border:none;
  border-radius:4px;
  font-size:.85rem;
  padding:2px 8px;
  cursor:pointer;
  font-weight:bold;
}
.row-actions button.approve:hover{ background:#16a34a; }

/* === Quill dark mode === */
[data-theme="dark"] .ql-toolbar{ background:var(--bg); border-color:var(--border) !important; }
[data-theme="dark"] .ql-container{ border-color:var(--border) !important; }
[data-theme="dark"] .ql-editor{ color:var(--txt); }
[data-theme="dark"] .ql-toolbar .ql-stroke{ stroke:var(--txt); }
[data-theme="dark"] .ql-toolbar .ql-fill{ fill:var(--txt); }
[data-theme="dark"] .ql-toolbar .ql-picker-label{ color:var(--txt); }
[data-theme="dark"] .ql-toolbar .ql-picker-options{ background:var(--card); border-color:var(--border); }
[data-theme="dark"] .ql-snow .ql-picker.ql-expanded .ql-picker-options{ background:var(--card); }

@media print{
  body{ width:100%; }
  .info, .floating-tooltip{ display:none !important; }
  .module, .annual-card, .level-cell{
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
