/* Estilo PRIMATE (MDI desktop Windows XP/Vista) — paleta y medidas segun DESIGN.md de primate */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  font-size: 12px;
  color: #1a1a1a;
  background: #ababab;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- titlebar ---------- */
#titlebar {
  height: 32px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg,#f0f0f0,#d8d8d8);
  border-bottom: 1px solid #aaa; padding: 0 8px; font-weight: 600;
}
.qa-btns, .win-btns { display: flex; gap: 2px; }
.qa-btns button, .win-btns button {
  width: 24px; height: 24px; border: 1px solid transparent; background: transparent;
  color: #3d3d3d; border-radius: 2px; cursor: pointer; font-size: 11px;
}
.qa-btns button:hover, .win-btns button:hover { background: #e0e0e0; border-color: #b8b8b8; }
.win-btns button.close:hover { background: #c0392b; color: #fff; }

/* ---------- ribbon ---------- */
#ribbon { flex: 0 0 auto; background: #fff; border-bottom: 1px solid #aaa; }
#ribbon-tabs { display: flex; background: linear-gradient(180deg,#e8e8e8,#d8d8d8); border-bottom: 1px solid #b0b0b0; padding-left: 6px; }
#ribbon-tabs .tab { padding: 6px 16px; font-size: 11px; font-weight: 600; color: #3d3d3d; cursor: pointer; }
#ribbon-tabs .tab.active { background: #fff; border-left: 1px solid #b0b0b0; border-right: 1px solid #b0b0b0; color: #1a1a1a; }
#ribbon-panel { height: 88px; display: flex; align-items: stretch; padding: 4px 8px; gap: 2px; }
.rgroup { display: flex; flex-direction: column; padding: 2px 10px; }
.rgroup .rgroup-btns { display: flex; gap: 4px; flex: 1; align-items: center; }
.rgroup .rgroup-lbl { text-align: center; font-size: 10px; color: #666; margin-top: 2px; }
.rsep { width: 1px; background: #c8c8c8; margin: 4px 4px; }
.rbtn-lg { width: 60px; height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: transparent; border: 1px solid transparent; border-radius: 3px; cursor: pointer; font-size: 10px; color: #1a1a1a; line-height: 1.15; }
.rbtn-lg:hover { background: #f0f0f0; border-color: #d0d0d0; }
.rbtn-col { display: flex; flex-direction: column; gap: 2px; justify-content: center; }
.rbtn-sm { height: 19px; display: flex; align-items: center; gap: 5px; padding: 0 6px; background: transparent; border: 1px solid transparent; border-radius: 2px; cursor: pointer; font-size: 10.5px; color: #1a1a1a; white-space: nowrap; }
.rbtn-sm:hover { background: #f0f0f0; border-color: #d0d0d0; }

/* ---------- doc tabs ---------- */
#doc-tabs { flex: 0 0 auto; display: flex; background: #d8d8d8; border-bottom: 1px solid #aaa; padding: 3px 4px 0; gap: 2px; }
.doctab { height: 24px; display: flex; align-items: center; gap: 8px; padding: 0 10px; font-size: 11px; color: #444; background: #c8c8c8; border: 1px solid #aaa; border-bottom: none; border-radius: 3px 3px 0 0; }
.doctab.active { height: 26px; background: #e8e8e8; color: #1a1a1a; font-weight: 600; }

/* ---------- workspace ---------- */
#workspace { flex: 1 1 auto; background: #e8e8e8; padding: 10px; overflow: auto; }

.toolbar { display: flex; gap: 6px; padding: 6px 8px; background: #f5f5f5; border: 1px solid #c8c8c8; border-radius: 3px 3px 0 0; }
.tbtn { height: 22px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 11px; color: #1a1a1a; background: linear-gradient(180deg,#fff,#e6e6e6); border: 1px solid #b8b8b8; border-radius: 3px; cursor: pointer; }
.tbtn:hover { background: linear-gradient(180deg,#fafafa,#dcdcdc); }
.tbtn.primary { background: linear-gradient(180deg,#3d3d3d,#2b2b2b); color: #fff; border-color: #1a1a1a; }
.tbtn.success { background: linear-gradient(180deg,#3cb85a,#28a745); color: #fff; border-color: #1e7e34; }

.searchbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #fff; border: 1px solid #c8c8c8; border-top: none; }
.searchbar input { height: 22px; border: 1px solid #aaa; border-radius: 2px; padding: 0 6px; font-size: 11px; width: 220px; font-family: inherit; }
.searchbar input:focus { outline: none; border-color: #3d3d3d; box-shadow: 0 0 0 2px #3d3d3d20; }
.searchbar .cant { margin-left: auto; color: #444; }

.grid-wrap { border: 1px solid #c8c8c8; border-top: none; background: #fff; }
table.data-grid { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-grid thead th { background: #eef4fa; border-bottom: 1px solid #a8c0d8; border-right: 1px solid #e4e4e4; text-align: left; padding: 3px 8px; font-weight: 600; }
.data-grid tbody td { padding: 3px 8px; border-bottom: 1px solid #e4e4e4; border-right: 1px solid #e4e4e4; }
.data-grid tbody tr:nth-child(even) { background: #f0f6fc; }
.data-grid tbody tr:hover { background: #ececec; cursor: pointer; }
.data-grid td.num, .data-grid th.num { text-align: right; }
.cat-chip { font-weight: 700; border: 1px solid #b0b0b0; border-radius: 2px; padding: 1px 6px; background: #f5f5f5; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 2px; font-size: 10px; font-weight: 600; }
.badge.green { background: #d4edda; color: #155724; }
.badge.yellow { background: #fff3cd; color: #856404; }
.badge.red { background: #f8d7da; color: #721c24; }
.badge.gray { background: #e2e3e5; color: #383d41; }

#statusbar { flex: 0 0 auto; height: 22px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: linear-gradient(180deg,#e8e8e8,#d8d8d8); border-top: 1px solid #aaa; font-size: 10.5px; color: #444; }
.sb-sep { width: 1px; height: 12px; background: #b0b0b0; }

.state-msg { padding: 30px; color: #666; font-size: 12px; text-align: center; }

/* ---------- ficha de cliente (patron documento) ---------- */
.back-link { display: inline-block; margin-bottom: 10px; font-size: 11px; color: #3d3d3d; text-decoration: underline; cursor: pointer; background: none; border: none; padding: 0; }
.ficha-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ficha-id { display: flex; align-items: center; gap: 12px; }
.ficha-avatar { width: 40px; height: 40px; border-radius: 3px; background: #d0e8f8; color: #0c4a7a; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.ficha-id h1 { font-size: 14px; margin: 0 0 2px; font-weight: 700; }
.ficha-id .meta { font-size: 11px; color: #666; }

.doc-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 10px; }
@media (max-width: 800px) { .doc-grid { grid-template-columns: 1fr; } }

.groupbox { border: 1px solid #cccccc; border-radius: 3px; background: #fff; margin-bottom: 10px; }
.groupbox-title { background: linear-gradient(180deg,#f5f5f5,#e6e6e6); border-bottom: 1px solid #cccccc; padding: 4px 10px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; color: #1a1a1a; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.groupbox-title-btn { text-transform: none; letter-spacing: normal; font-weight: 600; font-size: 10px; background: #fff; border: 1px solid #b8b8b8; border-radius: 2px; padding: 1px 7px; cursor: pointer; color: #1a1a1a; }
.groupbox-title-btn:hover { background: #f0f0f0; }
.check-row.togglable { cursor: pointer; }
.check-row.togglable:hover { background: #f5f5f5; }
.groupbox-body { padding: 8px 10px; }

.form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.form-row:last-child { margin-bottom: 0; }
.form-label { width: 140px; flex-shrink: 0; font-size: 11px; color: #444; text-align: right; }
.form-input { flex: 1; height: 22px; border: 1px solid #aaa; border-radius: 2px; padding: 0 6px; font-size: 11px; font-family: inherit; background: #fff; }
.form-input[readonly] { background: #fffbcc; border-color: #e6d980; color: #5a5230; }

.progress-track { height: 12px; border: 1px solid #cccccc; border-radius: 2px; background: #f0f0f0; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(180deg,#ffce3a,#e0a800); }
.progress-txt { font-size: 10.5px; color: #444; margin-top: 5px; }

.check-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px dashed #ddd; font-size: 11px; }
.check-row:last-child { border-bottom: none; }

.doc-file-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 11px; border-bottom: 1px solid #eee; }
.doc-file-row:last-child { border-bottom: none; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-overlay.hidden { display: none; }
.modal { width: 460px; max-width: 92vw; background: #fff; border: 1px solid #aaa; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; background: linear-gradient(180deg,#3d3d3d,#2b2b2b); color: #fff; padding: 8px 12px; font-size: 12px; font-weight: 700; }
.modal-header button { background: transparent; border: none; color: #fff; cursor: pointer; font-size: 12px; opacity: 0.8; }
.modal-header button:hover { opacity: 1; }
.modal-body { padding: 14px 16px; max-height: 60vh; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; background: #f5f5f5; border-top: 1px solid #d0d0d0; }
.modal-error { background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 3px; padding: 6px 10px; font-size: 11px; color: #721c24; margin-bottom: 10px; display: none; }
.modal-error.show { display: block; }
.modal-success { background: #d4edda; border: 1px solid #c3e6cb; border-radius: 3px; padding: 10px; font-size: 11.5px; color: #155724; }
.modal-success .pw { font-family: Consolas, monospace; font-weight: 700; font-size: 13px; background: #fff; border: 1px dashed #155724; padding: 4px 8px; border-radius: 2px; display: inline-block; margin-top: 4px; }

/* ---------- login (no MDI, pantalla previa) ---------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #ababab; }
.login-card { width: 340px; background: #fff; border: 1px solid #aaa; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); overflow: hidden; }
.login-card .hdr { background: linear-gradient(180deg,#f0f0f0,#d8d8d8); border-bottom: 1px solid #aaa; padding: 10px 16px; font-size: 13px; font-weight: 700; color: #1a1a1a; }
.login-card .body { padding: 18px 20px 20px; }
.login-field { margin-bottom: 10px; }
.login-field label { display: block; font-size: 11px; color: #444; margin-bottom: 3px; }
.login-field input { width: 100%; height: 22px; border: 1px solid #aaa; border-radius: 2px; padding: 0 6px; font-size: 11px; font-family: inherit; }
.login-field input:focus { outline: none; border-color: #3d3d3d; box-shadow: 0 0 0 2px #3d3d3d20; }
.login-btn { width: 100%; height: 26px; margin-top: 6px; background: linear-gradient(180deg,#3d3d3d,#2b2b2b); color: #fff; border: 1px solid #1a1a1a; border-radius: 3px; font-size: 11px; font-weight: 600; cursor: pointer; }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-error { background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 3px; padding: 6px 10px; font-size: 11px; color: #721c24; margin-bottom: 10px; display: none; }
.login-error.show { display: block; }
.login-btn-outline { width: 100%; height: 24px; margin-top: 10px; background: #fff; color: #3d3d3d; border: 1px solid #b8b8b8; border-radius: 3px; font-size: 11px; cursor: pointer; }
.login-btn-outline:hover { background: #f0f0f0; }
