:root {
  --blue: #0EA5E9; --blue-d: #0284C7; --blue-l: #E0F2FE;
  --ink: #1F2328; --grey: #6B7280; --line: #E3E8EE; --bg: #F5F7FA; --card: #FFFFFF;
  --danger: #DC2626; --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-d); }

/* ---- botones e inputs ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #C9D2DC; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #EDF1F5; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-l); }
label.f { display: block; margin-bottom: 11px; }
label.f span { display: block; font-size: 12px; color: var(--grey); margin-bottom: 4px; font-weight: 500; }
label.f input.empty, label.f textarea.empty { background: #FFFBEA; border-color: #F3D774; }

/* ---- login ---- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; }
.login img { height: 30px; margin-bottom: 22px; }
.login h1 { font-size: 17px; margin: 0 0 4px; }
.login p { color: var(--grey); margin: 0 0 22px; font-size: 13px; }
.login .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---- layout ---- */
.top { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top img.logo { height: 22px; }
.top .sp { flex: 1; }
.top .who { color: var(--grey); font-size: 12.5px; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 28px 20px; }
.head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.head h1 { font-size: 20px; margin: 0; }

.list { display: grid; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
.item:hover { border-color: #C9D2DC; }
.item .ic { width: 38px; height: 38px; border-radius: 9px; background: var(--blue-l); color: var(--blue-d); display: grid; place-items: center; font-weight: 700; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { color: var(--grey); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--grey); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---- editor ---- */
.editor { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; height: calc(100vh - 58px); }
.side { background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 10px; }
.tabs button { border: 0; background: none; padding: 12px 12px 10px; cursor: pointer; color: var(--grey); font-weight: 500; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--blue); }
.pane { flex: 1; overflow: auto; padding: 16px 18px 40px; }
.pane h4 { margin: 16px 0 10px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--blue-d); }
.pane h4:first-child { margin-top: 0; }
.pane textarea.code { font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: calc(100vh - 230px); resize: vertical; white-space: pre-wrap; }
.help { font-size: 12px; color: var(--grey); background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.help code { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11.5px; }
.prow { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 10px; }
.prow .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.prow .acts { display: flex; gap: 4px; justify-content: flex-end; }
.prow label.f { margin-bottom: 6px; }

.preview { overflow: auto; padding: 28px; }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.name-in { max-width: 45vw; font-weight: 600; border-color: transparent !important; background: transparent !important; }
.name-in:hover, .name-in:focus { border-color: var(--line) !important; background: #fff !important; }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--blue-l); color: var(--blue-d); font-weight: 600; }
.badge.warn { background: #FEF3C7; color: #92400E; }

/* ---- documento ---- */
.paper { max-width: 794px; margin: 0 auto; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 30px rgba(0,0,0,.05); padding: 56px 72px 72px; font-family: Roboto, Arial, sans-serif; font-size: 12.6px; line-height: 1.55; color: #1F2328; }
.paper .ph { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.paper .ph img { height: 26px; }
.paper .ph span { font-size: 8.5px; letter-spacing: .18em; color: var(--grey); }
.paper mark { background: #FFF3A3; padding: 0 2px; }
.c-title { font-size: 21px; line-height: 1.2; margin: 0 0 6px; }
.c-sub { color: var(--grey); font-size: 11.5px; margin: 0 0 22px; padding-bottom: 12px; border-bottom: 2px solid var(--blue); }
.c-sec { color: var(--blue); font-size: 13px; letter-spacing: .14em; margin: 22px 0 10px; padding-bottom: 5px; border-bottom: 1px solid #D9E2EA; }
.c-cl { font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; margin: 18px 0 8px; }
.c-cl span { color: var(--blue); }
.c-p { text-align: justify; margin: 0 0 9px; }
.c-list { margin: 0 0 10px; padding-left: 26px; text-align: justify; }
.c-list li { margin-bottom: 5px; }
.c-list li::marker { color: var(--blue); font-weight: 700; }
.c-break { border-top: 1px dashed #CBD5E1; margin: 36px -72px 30px; position: relative; }
.c-break::after { content: 'salto de página'; position: absolute; right: 12px; top: -9px; background: #fff; font-size: 10px; color: #94A3B8; padding: 0 6px; }
.c-annex { color: var(--blue); font-weight: 700; letter-spacing: .18em; font-size: 12px; margin: 0 0 4px; }
.c-annex-t { font-size: 19px; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 2px solid var(--blue); }
.c-prices { width: 100%; border-collapse: collapse; margin: 6px 0 16px; font-size: 12px; }
.c-prices th { background: #1F2328; color: #fff; text-align: left; font-size: 10.5px; letter-spacing: .08em; padding: 9px 10px; }
.c-prices td { padding: 9px 10px; border-bottom: 1px solid #E3EAF0; vertical-align: top; }
.c-prices tr.alt td { background: #F3F7FA; }
.c-prices small { display: block; color: var(--grey); font-size: 10.5px; margin-top: 2px; }
.c-prices .r { text-align: right; }
.c-prices .hl { color: var(--blue); }
.c-sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 70px; }
.c-sigs div { border-top: 1px solid #1F2328; padding-top: 7px; display: flex; flex-direction: column; font-size: 11.5px; }
.c-sigs span { color: var(--grey); }

/* ---- modal / drawer ---- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; padding: 22px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; background: #fff; border-left: 1px solid var(--line); z-index: 21; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.06); }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer header h3 { margin: 0; font-size: 15px; }
.drawer .body { overflow: auto; padding: 12px; }
.ver { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; }
.ver.cur { border-color: var(--blue); background: #F7FCFF; }
.ver .h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ver small { color: var(--grey); }
.ver p { margin: 4px 0 8px; font-size: 13px; }
.ver .acts { display: flex; gap: 4px; flex-wrap: wrap; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 9px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; font-size: 13px; }
#toast.on { opacity: 1; transform: translateX(-50%); }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .pane textarea.code { min-height: 360px; }
  .paper { padding: 32px 22px; }
  .c-break { margin: 30px -22px; }
  .top { padding: 0 12px; height: auto; min-height: 58px; flex-wrap: wrap; padding-block: 8px; }
}
[hidden] { display: none !important; }
.name-in { width: 320px; }
