@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --ac: #D32428;
  --ac-hover: #E31907;
  --al: #fde8e8;
  --bg: #f8f8f8;
  --sf: #fff;
  --tx: #1f1f1f;
  --tm: #727272;
  --bd: #e0e0e0;
  --dark: #1F1F1F;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
}

input, select, textarea, button { outline: none; font-family: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--ac) !important; }
::placeholder { color: var(--tm); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bd); border-radius: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.btn-primary { background: var(--ac); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { background: var(--bd); color: var(--tm); cursor: not-allowed; }
.btn-outline { background: transparent; border: 1px solid var(--bd); color: var(--tx); }
.btn-outline:hover { border-color: var(--ac); color: var(--ac); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 12px; }

.select {
  height: 30px; padding: 0 24px 0 8px; border: 1px solid var(--bd); border-radius: 6px;
  font-size: 12px; background: var(--sf); color: var(--tx); font-family: inherit; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; appearance: none;
}

/* Forms */
.form-label {
  display: block; font-size: 11px; font-weight: 700; color: var(--tm);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px;
}
.form-input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 2px solid var(--bd); border-radius: 8px;
  font-size: 14px; background: var(--sf); color: var(--tx);
}

/* Cards */
.card {
  background: var(--sf); border: 1px solid var(--bd); border-radius: 12px;
  padding: 14px 18px;
}
/* Language buttons — uniform height */
.lang-btn {
  background: var(--sf); border: 1px solid var(--bd); border-radius: 12px;
  padding: 10px 16px; min-width: 140px; position: relative;
  display: flex; flex-direction: column; transition: all .15s;
}
.lang-btn.selected { border: 2px solid var(--ac); }
.lang-btn-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--tm); margin-bottom: 2px; }
.lang-btn-name { font-weight: 700; font-size: 13px; color: var(--tx); }
.lang-btn-meta { font-size: 11px; color: var(--tm); }

.lang-card-delete {
  position: absolute; top: 5px; right: 7px; background: none; border: none;
  cursor: pointer; color: var(--ac); font-size: 14px; line-height: 1; padding: 2px;
  transition: opacity .15s;
}
.lang-card-delete:hover { opacity: .7; }

.badge {
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}

.progress-bar { height: 3px; background: var(--bd); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .5s; }

/* Type colors — breed palette */
.type-title, .type-subtitle { color: #D32428; background: #fde8e8; }
.type-html, .type-body { color: #547ec0; background: #e8f0fc; }
.type-question { color: #026257; background: #e0f2f1; }
.type-choice { color: #8e24aa; background: #f3e5f5; }
.type-feedback { color: #e65100; background: #fff3e0; }
.type-alt { color: #727272; background: #f5f5f5; }
.type-label, .type-media { color: #026257; background: #e0f2f1; }

/* Layout */
.topbar {
  background: var(--sf); border-bottom: 1px solid var(--bd);
  padding: 10px 20px; display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 100;
}
.container { max-width: 1600px; margin: 0 auto; padding: 16px 20px; }

/* File-level headers — same column layout as rows */
.file-header {
  display: flex; align-items: stretch; gap: 0;
  margin-top: 24px;
  background: var(--bg); border: 1px solid var(--bd);
  border-bottom: 2px solid var(--ac);
  font-weight: 700; font-size: 12px; color: var(--tx);
  min-height: 36px;
}
.file-header:first-child { margin-top: 0; }
.file-header .col-source { font-weight: 700; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.file-header .col-lang { border-right: 1px solid var(--bd); }
.file-header .col-lang:last-child { border-right: none; }
.file-header-lang { font-size: 10px; font-weight: 700; color: var(--tm); text-transform: uppercase; letter-spacing: .04em; }
.file-deepl-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 7px; border: 1px solid var(--bd); border-radius: 4px;
  background: var(--sf); color: var(--tm); font-size: 10px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .15s; white-space: nowrap;
}
.file-deepl-btn:hover { border-color: var(--ac); color: var(--ac); }
.file-deepl-btn:disabled { opacity: .5; cursor: not-allowed; }
.file-deepl-btn i { color: var(--ac); font-size: 11px; }

/* Section headers */
.section-header {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; cursor: pointer;
  background: var(--dark); color: #fff; border-radius: 0;
  margin-top: 0; font-weight: 600; font-size: 11px;
}
.section-header.expanded { border-radius: 0; }
.section-count {
  font-size: 9px; background: rgba(255,255,255,.15);
  padding: 1px 6px; border-radius: 10px;
}

/* Translation table */
.section-body {
  border: 1px solid var(--bd); border-top: none;
  border-radius: 0; overflow: hidden;
}

.col-header {
  display: flex; align-items: center; gap: 0;
  padding: 0; font-size: 10px; font-weight: 700;
  color: var(--tm); text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 2px;
}

.trow {
  display: flex; align-items: stretch; gap: 0;
  border-bottom: 1px solid var(--bd);
  min-height: 40px;
}
.trow:last-child { border-bottom: none; }

.col-type { width: 70px; flex-shrink: 0; padding: 6px 8px; display: flex; align-items: flex-start; padding-top: 8px; }
.col-source {
  flex: 1; min-width: 0; padding: 6px 12px;
  font-size: 14px; line-height: 1.5; color: var(--tx);
  border-right: 3px solid var(--ac);
}
.col-lang {
  flex: 1; min-width: 0; padding: 4px 6px;
  border-right: 1px solid var(--bd);
}
.col-lang:last-child { border-right: none; }

.col-header .col-type { padding: 4px 8px; }
.col-header .col-source { padding: 4px 12px; border-right: 3px solid var(--ac); }
.col-header .col-lang { padding: 4px 6px; border-right: 1px solid var(--bd); }
.col-header .col-lang:last-child { border-right: none; }

.source-text {
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.source-rich { font-size: 14px; line-height: 1.5; }
.source-rich h1, .source-rich h2, .source-rich h3, .source-rich h4, .source-rich h5, .source-rich h6 {
  font-size: 14px; font-weight: 600; margin: 0; line-height: 1.5;
}
.source-rich p { margin: 0; }
.source-rich ul, .source-rich ol { margin: 0; padding-left: 16px; }
.source-rich li { margin: 0; }
.source-rich em, .source-rich strong { font-size: inherit; }
.source-rich a { color: var(--ac); text-decoration: underline; }
.source-rich figure { margin: 0; font-style: italic; }

/* Editable cell */
.tcell { display: flex; flex-direction: column; height: 100%; }
.tcell-input {
  flex: 1; width: 100%; border: 1px solid transparent; border-radius: 4px;
  padding: 4px 8px; font-size: 14px; line-height: 1.5;
  background: transparent; color: var(--tx); resize: none;
  font-family: inherit; transition: border-color .15s, background .15s;
  min-height: 28px;
}
.tcell-input:hover { background: rgba(0,0,0,.02); }
.tcell-input:focus, .tcell-input:focus-within { border-color: var(--ac); background: #fff; box-shadow: 0 0 0 2px rgba(211,36,40,.1); }
.tcell-input::placeholder { color: var(--bd); }

/* Rich-text contenteditable cell */
.tcell-rich { cursor: text; overflow: hidden; }
.tcell-rich:empty::before { content: attr(data-placeholder); color: var(--bd); }
.tcell-rich h1, .tcell-rich h2, .tcell-rich h3, .tcell-rich h4, .tcell-rich h5, .tcell-rich h6 {
  font-size: 14px; font-weight: 600; margin: 0; line-height: 1.5;
}
.tcell-rich p { margin: 0; }
.tcell-rich ul, .tcell-rich ol { margin: 0; padding-left: 16px; }
.tcell-rich li { margin: 0; }
.tcell-rich em, .tcell-rich strong { font-size: inherit; }
.tcell-rich a { color: var(--ac); text-decoration: underline; pointer-events: none; }
.tcell-rich figure { margin: 0; font-style: italic; }
.tcell-rich br { line-height: 0.5; }

.tcell-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 2px; min-height: 16px;
}

/* HTML source toggle */
.html-toggle {
  font-size: 9px; font-weight: 700; font-family: monospace;
  padding: 1px 4px; border-radius: 3px; border: 1px solid var(--bd);
  background: transparent; color: var(--tm); cursor: pointer;
  transition: all .15s; line-height: 1;
}
.html-toggle:hover { border-color: var(--ac); color: var(--ac); }
.html-toggle.active { background: var(--dark); color: #fff; border-color: var(--dark); }

/* Code textarea for raw HTML */
.tcell-code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px; line-height: 1.4; white-space: pre-wrap;
  background: var(--dark); color: #e6e6e6; border-radius: 4px;
  padding: 6px 8px;
}
.tcell-code:focus { border-color: var(--ac); box-shadow: 0 0 0 2px rgba(211,36,40,.15); }

/* Floating rich-text toolbar */
.rich-toolbar {
  position: absolute; z-index: 500;
  display: flex; align-items: center; gap: 2px;
  padding: 3px 4px; background: var(--sf);
  border: 1px solid var(--bd); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.rich-toolbar button {
  width: 26px; height: 24px; border: none; border-radius: 4px;
  background: transparent; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  font-size: 13px; color: var(--tx); transition: background .1s;
}
.rich-toolbar button:hover { background: var(--bg); }
.tb-sep { width: 1px; height: 16px; background: var(--bd); margin: 0 2px; }
.tb-html { font-family: monospace; font-size: 10px; font-weight: 700; }
.tb-html.active { background: var(--ac); color: #fff; border-radius: 4px; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(4px);
}
.modal {
  background: var(--sf); border-radius: 16px; padding: 24px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2); border: 1px solid var(--bd);
  position: relative;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer; color: var(--ac);
  padding: 4px; border-radius: 6px; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.modal-close:hover { color: var(--ac-hover, #E31907); background: var(--al); }

/* Icon buttons — clickable icons in breed-rot */
.icon-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--bd); font-size: 15px; line-height: 1; transition: color .15s;
  display: inline-flex; align-items: center;
}
.icon-btn:hover { color: var(--ac); }
.icon-btn-danger:hover { color: #ef4444; }

/* User table */
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--tm); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--bd); background: var(--bg); }
.user-table td { padding: 8px 12px; border-bottom: 1px solid var(--bd); vertical-align: middle; }
.user-table tr:last-child td { border-bottom: none; }
.user-table-add td { padding-top: 12px; background: var(--bg); }
.user-table-input { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--bd); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--sf); color: var(--tx); }

/* Upload zone */
.dropzone {
  border: 2px dashed var(--bd); border-radius: 12px;
  padding: 24px 16px; text-align: center; cursor: pointer;
  background: var(--sf); transition: all .2s;
}
.dropzone.active { border-color: var(--ac); background: var(--al); }

/* Login */
.onboarding {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px 20px;
}
.login-box {
  max-width: 440px; width: 100%; background: var(--sf);
  border: 1px solid var(--bd); border-radius: 16px; padding: 32px;
}
.login-box input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 2px solid var(--bd); border-radius: 8px;
  font-size: 15px; background: var(--sf); color: var(--tx);
}
