/* ============================================================
   CASA MILITAR — GERADOR DE DOCUMENTOS
   Identidade institucional: azul-marinho + ouro do brasão
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  --navy-900: #0a1f44;
  --navy-800: #0e2a5c;
  --navy-700: #143a78;
  --navy-600: #1d4fa8;
  --navy-100: #e7edf7;
  --navy-50:  #f3f6fb;

  --gold-600: #a9842f;
  --gold-500: #c79a3a;
  --gold-400: #d9b35a;
  --gold-100: #f6ecd3;

  --ink:      #1a2233;
  --ink-soft: #4a5468;
  --ink-mute: #7b8497;
  --line:     #dfe4ec;
  --line-soft:#ecf0f6;
  --bg:       #eef1f6;
  --card:     #ffffff;

  --ok:       #1f7a4d;
  --ok-bg:    #e6f4ec;
  --danger:   #c0392b;
  --danger-bg:#fdecea;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(10,31,68,.06), 0 1px 3px rgba(10,31,68,.05);
  --shadow-md: 0 4px 16px rgba(10,31,68,.08);
  --shadow-lg: 0 18px 50px rgba(10,31,68,.18);
  --focus: 0 0 0 3px rgba(29,79,168,.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Public Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-image:
    radial-gradient(1200px 600px at 50% -200px, #f7f9fc 0%, var(--bg) 60%);
  min-height: 100vh;
}

/* ---------- App shell ---------- */
.app {
  max-width: 940px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ---------- Header ---------- */
.masthead {
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.masthead__accent {
  height: 6px;
  background: linear-gradient(90deg, var(--navy-800) 0%, var(--navy-600) 50%, var(--navy-800) 100%);
  position: relative;
}
.masthead__accent::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
}
.masthead__row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 26px;
}
.brasao {
  width: 62px;
  height: 62px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 2px 4px rgba(10,31,68,.18));
}
.masthead__titles { line-height: 1.25; }
.masthead__org {
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold-600);
  font-weight: 700;
  margin: 0 0 2px;
}
.masthead__title {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy-800);
  margin: 0;
  letter-spacing: -.01em;
}
.masthead__sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 3px 0 0;
  font-weight: 400;
}
.masthead__gear {
  margin-left: auto;
  align-self: flex-start;
  background: var(--navy-50);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  transition: .15s;
}
.masthead__gear:hover { background: var(--navy-100); color: var(--navy-700); }
.masthead__gear svg { width: 18px; height: 18px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: none;
  border-bottom: none;
  padding: 0 16px;
}
.tab {
  appearance: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-mute);
  padding: 16px 16px 14px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 3px solid transparent;
  transition: color .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--navy-700); }
.tab svg { width: 17px; height: 17px; opacity: .85; }
.tab[aria-selected="true"] {
  color: var(--navy-800);
  border-bottom-color: var(--gold-500);
}
.tab[aria-selected="true"] svg { opacity: 1; }

/* ---------- Panel ---------- */
.panel-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 26px;
}
.panel { display: none; }
.panel.is-active { display: block; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .panel.is-active { animation: fade .25s ease both; }
}
@keyframes fade { from { transform: translateY(5px); } to { transform: none; } }

.panel__intro {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 22px;
  line-height: 1.5;
}

/* ---------- Block ---------- */
.block {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--card);
}
.block__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 18px;
  background: var(--navy-50);
  border-bottom: 1px solid var(--line);
}
.block__num {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--navy-800);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid; place-items: center;
  flex: none;
}
.block__title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--navy-800);
  margin: 0;
}
.block__hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 500;
}
.block__body { padding: 18px; }

/* ---------- Grid / fields ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.col-span-2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.req { color: var(--gold-600); font-weight: 700; }

.input, .select, textarea {
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  min-height: 44px;
}
.input::placeholder { color: var(--ink-mute); }
.input:focus, .select:focus, textarea:focus, .combo__input:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: var(--focus);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%237b8497' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
.field--invalid .input,
.field--invalid .select,
.field--invalid .combo__input {
  border-color: var(--danger);
}
.field__err {
  font-size: 11.5px;
  color: var(--danger);
  display: none;
}
.field--invalid .field__err { display: block; }

/* ---------- Combobox (searchable) ---------- */
.combo { position: relative; }
.combo__input { padding-right: 34px; }
.combo__caret {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--ink-mute);
}
.combo__list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  max-height: 256px;
  overflow-y: auto;
  display: none;
  padding: 4px;
}
.combo__list.is-open { display: block; }
.combo__opt {
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.3;
}
.combo__opt small { display: block; color: var(--ink-mute); font-size: 11.5px; margin-top: 1px; }
.combo__opt:hover, .combo__opt.is-active { background: var(--navy-50); }
.combo__opt mark { background: var(--gold-100); color: var(--navy-800); border-radius: 3px; padding: 0 1px; }
.combo__empty { padding: 12px; text-align: center; color: var(--ink-mute); font-size: 13px; }

/* ---------- Servidores ---------- */
.servidor-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.servidor-row__num {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--navy-100); color: var(--navy-800);
  font-size: 12.5px; font-weight: 700;
  display: grid; place-items: center;
}
.servidor-row__meta {
  font-size: 11.5px; color: var(--ink-mute); margin-top: 4px;
  display: flex; gap: 14px; flex-wrap: wrap;
}
.servidor-row__meta span strong { color: var(--ink-soft); font-weight: 600; }
.icon-btn {
  appearance: none; border: 1.5px solid var(--line); background: #fff;
  width: 38px; height: 38px; border-radius: var(--r-sm);
  color: var(--ink-mute); cursor: pointer; display: grid; place-items: center;
  transition: .15s; flex: none;
}
.icon-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.icon-btn svg { width: 16px; height: 16px; }

.add-btn {
  appearance: none;
  width: 100%;
  border: 1.5px dashed var(--navy-600);
  background: var(--navy-50);
  color: var(--navy-700);
  font-family: inherit; font-weight: 600; font-size: 13.5px;
  padding: 12px; border-radius: var(--r-sm);
  cursor: pointer; transition: .15s;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.add-btn:hover { background: var(--navy-100); }
.add-btn:disabled { opacity: .45; cursor: not-allowed; }
.add-btn svg { width: 15px; height: 15px; }

/* ---------- Check options ---------- */
.checks { display: grid; gap: 9px; }
.checks--2 { grid-template-columns: 1fr 1fr; }
.check {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer; transition: .15s;
  background: #fff;
}
.check:hover { border-color: var(--navy-100); background: var(--navy-50); }
.check input { display: none; }
.check__box {
  width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid var(--line); flex: none; margin-top: 1px;
  display: grid; place-items: center; transition: .15s;
}
.check__box svg { width: 12px; height: 12px; opacity: 0; color: #fff; transition: .12s; }
.check input:checked + .check__box { background: var(--navy-700); border-color: var(--navy-700); }
.check input:checked + .check__box svg { opacity: 1; }
.check input:checked ~ .check__txt .check__title { color: var(--navy-800); }
.check:has(input:checked) { border-color: var(--navy-600); background: var(--navy-50); }
.check__title { font-size: 13.5px; font-weight: 600; color: var(--ink); display: block; }
.check__desc { font-size: 11.5px; color: var(--ink-mute); margin-top: 2px; line-height: 1.4; display: block; }

/* ---------- Notice ---------- */
.notice {
  display: none;
  align-items: flex-start; gap: 11px;
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: var(--r-sm);
  background: var(--gold-100);
  border: 1px solid #ecd9a8;
  font-size: 13px;
  color: #6b531c;
  line-height: 1.45;
}
.notice.is-on { display: flex; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--gold-600); }
.notice strong { color: #5a4516; }

/* ---------- Submit ---------- */
.actions { margin-top: 22px; }
.btn-primary {
  appearance: none; border: none; width: 100%;
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  color: #fff; font-family: inherit; font-weight: 700; font-size: 15px;
  letter-spacing: .01em;
  padding: 15px; border-radius: var(--r-sm);
  cursor: pointer; transition: .15s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-primary svg { width: 18px; height: 18px; }
.btn-primary .spinner { display: none; }
.btn-primary.is-loading .btn-primary__label,
.btn-primary.is-loading > svg:first-child { display: none; }
.btn-primary.is-loading .spinner { display: inline-block; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
.appfoot {
  text-align: center; margin-top: 22px;
  font-size: 12px; color: var(--ink-mute);
}
.appfoot strong { color: var(--ink-soft); font-weight: 600; }

/* ---------- Modal / toast ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,31,68,.45);
  backdrop-filter: blur(3px);
  display: none; place-items: center;
  padding: 20px;
}
.overlay.is-open { display: grid; animation: fade .2s; }
.modal {
  background: #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 460px; width: 100%;
  overflow: hidden;
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.modal__head {
  display: flex; align-items: center; gap: 13px;
  padding: 22px 24px 16px;
}
.modal__icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.modal__icon--ok { background: var(--ok-bg); color: var(--ok); }
.modal__icon--err { background: var(--danger-bg); color: var(--danger); }
.modal__icon svg { width: 24px; height: 24px; }
.modal__h { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.modal__body { padding: 0 24px 22px; }
.modal__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); font-weight: 700; margin: 6px 0 4px; }
.modal__name { font-size: 14px; color: var(--ink); line-height: 1.45; word-break: break-word; }
.modal__doc {
  margin-top: 8px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--navy-50); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.modal__doc + .modal__doc { margin-top: 8px; }
.modal__doc svg { width: 20px; height: 20px; color: var(--navy-700); flex: none; }
.modal__doc-name { font-size: 13px; color: var(--ink); flex: 1; min-width: 0; word-break: break-word; }
.modal__actions { padding: 0 24px 24px; display: flex; gap: 10px; }
.btn-ghost, .btn-link {
  appearance: none; font-family: inherit; font-weight: 600; font-size: 14px;
  padding: 11px 16px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none;
}
.btn-ghost { background: #fff; border: 1.5px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--navy-50); }
.btn-link { background: var(--navy-700); border: none; color: #fff; flex: 1; }
.btn-link:hover { background: var(--navy-800); }
.btn-link svg { width: 16px; height: 16px; }

/* ---------- Settings modal ---------- */
.settings__field { margin-top: 14px; }
.settings__note { font-size: 12px; color: var(--ink-mute); line-height: 1.5; margin: 8px 0 0; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot--ok { background: var(--ok); }
.status-dot--off { background: var(--ink-mute); }
.conn-status { font-size: 12px; color: var(--ink-soft); margin-top: 12px; display: flex; align-items: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy-800); color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 12px 20px; border-radius: 100px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 120;
  display: flex; align-items: center; gap: 9px; max-width: 90vw;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; flex: none; }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .app { padding: 14px 12px 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .checks--2 { grid-template-columns: 1fr; }
  .masthead__row { padding: 16px 18px; gap: 13px; }
  .masthead__title { font-size: 18px; }
  .brasao { width: 50px; height: 50px; }
  .tabs { overflow-x: auto; padding: 0 8px; }
  .tab { padding: 14px 12px 12px; font-size: 13px; }
  .panel-wrap { padding: 18px 16px; }
  .block__body { padding: 15px; }
}
