/* STGS — Sistema de Gestão de Senhas · Desenvolvido e mantido por Deivid Silva */
:root {
  --bg: #f4f6fa; --panel: #ffffff; --text: #1c2333; --muted: #6b7489; --line: #e2e6ee;
  --primary: #2f5bea; --primary-h: #2148c7; --danger: #d23a3a; --warn: #c98a00; --ok: #1f9d55;
  --radius: 10px; --shadow: 0 2px 10px rgba(20, 30, 60, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151f; --panel: #1a202d; --text: #e6e9f0; --muted: #94a0b8; --line: #2a3242; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .3rem 0 .6rem; }
h2 { font-size: 1.35rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.error { color: var(--danger); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: .5rem; }
.spacer { flex: 1; }

.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-msg { color: var(--muted); }

/* Botões e formulários */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; margin-top: .5rem; }
.btn-icon { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; width: 2.4rem; cursor: pointer; font-size: 1rem; }
.btn-icon:hover { border-color: var(--primary); }

.field { display: block; margin-bottom: .9rem; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.hint { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.input-group { display: flex; gap: .35rem; }
.input-group input { flex: 1; }
.check-line { display: flex; gap: .5rem; align-items: center; margin: 1rem 0 .3rem; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .8rem; }
.gen-len { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; }
.gen-len input { flex: 1; }
.gen-out { font-size: 1.05rem; }

.meter { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; height: 1rem; }
.meter-bar { flex: 0 0 120px; height: 6px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.meter-bar::after { content: ""; position: absolute; inset: 0; width: 0; background: var(--danger); transition: width .2s; }
.meter.lvl1 .meter-bar::after { width: 25%; background: var(--danger); }
.meter.lvl2 .meter-bar::after { width: 50%; background: var(--warn); }
.meter.lvl3 .meter-bar::after { width: 75%; background: #7bb342; }
.meter.lvl4 .meter-bar::after { width: 100%; background: var(--ok); }
.meter-label { font-size: .78rem; color: var(--muted); }

/* Autenticação */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: .6rem; }
.brand small { display: block; color: var(--muted); font-size: .78rem; }
.brand-mark { font-size: 1.6rem; }
.credit { color: var(--muted); font-size: .75rem; margin-top: 1rem; }
.recovery-code { font-size: 1.15rem; letter-spacing: .05em; text-align: center; padding: 1rem; border: 2px dashed var(--primary); border-radius: 10px; margin: 1rem 0; word-break: break-all; user-select: all; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: 0 0 250px; background: var(--panel); border-right: 1px solid var(--line); padding: 1.2rem 1rem; display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: flex; flex-direction: column; gap: .2rem; }
.sidebar nav a { display: flex; gap: .6rem; padding: .55rem .7rem; border-radius: 8px; color: var(--text); }
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .6rem; }
.who small { display: block; color: var(--muted); }
.main { flex: 1; padding: 1.6rem 2rem; min-width: 0; }
.page-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .back { font-size: .9rem; }
.badge { font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.search { margin-bottom: 1rem; max-width: 420px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.client-card { display: flex; gap: .8rem; align-items: center; color: var(--text); }
.client-card:hover { border-color: var(--primary); text-decoration: none; }
.client-card small { display: block; }
.client-card.archived { opacity: .6; }
.avatar { width: 2.6rem; height: 2.6rem; flex: 0 0 2.6rem; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab { border: 1px solid transparent; border-bottom: none; background: none; color: var(--text); padding: .55rem .9rem; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit; }
.tab.active { background: var(--panel); border-color: var(--line); font-weight: 600; margin-bottom: -1px; }
.tab.add { color: var(--primary); }
.tab .count { margin-left: .4rem; font-size: .75rem; color: var(--muted); }

.items-head { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.items-head .search { flex: 1; min-width: 200px; }
.items { display: flex; flex-direction: column; gap: .4rem; }
.item { display: flex; align-items: center; gap: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .9rem; }
.item:hover { border-color: var(--primary); }
.item.broken { border-color: var(--danger); }
.item-main { flex: 1; display: flex; align-items: center; gap: .8rem; cursor: pointer; min-width: 0; }
.item-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; gap: .35rem; align-items: center; }
.type-badge { font-size: .72rem; padding: .15rem .5rem; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }

.item-view .kv { display: grid; grid-template-columns: 140px 1fr auto; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.item-view .k { color: var(--muted); font-size: .88rem; }
.item-view .val { word-break: break-all; margin: 0; white-space: pre-wrap; }
.item-view .notes { font-family: inherit; }
.kv-actions { display: flex; gap: .3rem; }
.custom-fields { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.custom-row { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: .4rem; align-items: center; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.fp { word-break: break-all; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: var(--bg); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(10, 15, 30, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 620px; background: var(--panel); border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1.2rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.2rem; border-top: 1px solid var(--line); }
.modal-foot.inline { padding: .5rem 0 0; border-top: none; }

/* Notificações */
#toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; }
.toast { padding: .75rem 1rem; border-radius: 10px; color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 380px; background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .item { flex-direction: column; align-items: stretch; }
  .item-view .kv { grid-template-columns: 1fr; }
  .custom-row { grid-template-columns: 1fr 1fr; }
}
@media print {
  .sidebar, .btn, .check-line, #toast { display: none !important; }
  .auth-card { border: none; box-shadow: none; }
}

/* Módulo 2 — equipe */
.mt { margin-top: 1rem; }
.block { display: block; }
.alert { background: rgba(201, 138, 0, .1); border: 1px solid var(--warn); border-radius: 8px; padding: .6rem .8rem; }
.row-attn td { background: rgba(201, 138, 0, .08); }
.status { font-size: .78rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.st-active { color: var(--ok); border-color: var(--ok); }
.st-pending_confirm, .st-invited { color: var(--warn); border-color: var(--warn); }
.st-disabled { color: var(--muted); }
.table td.actions { white-space: normal; }
.check-list { display: flex; flex-direction: column; gap: .3rem; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.check-item { display: flex; align-items: center; gap: .3rem; }
.fp-box { border: 1px dashed var(--primary); border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; }
.fp-big { font-size: 1.15rem; letter-spacing: .04em; text-align: center; word-break: break-all; }

/* Módulo 3 — 2FA, vencimentos, configurações */
.qr-wrap { display: flex; justify-content: center; margin: .8rem 0; }
.qr { background: #fff; padding: 6px; border-radius: 8px; image-rendering: pixelated; }
.code-input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .3rem; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .8rem; padding: .8rem; border: 2px dashed var(--primary); border-radius: 10px; margin: .6rem 0; text-align: center; user-select: all; }
.ok-msg { color: var(--ok); font-weight: 600; }
.due { font-size: .78rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.due-ok { color: var(--ok); }
.due-mid { color: #7a8a00; }
.due-soon { color: var(--warn); }
.due-over { color: #fff; background: var(--danger); border-color: var(--danger); }
.tab-exp { margin-left: auto; }
.grow { flex: 1; margin: 0; }
.upcoming { margin-bottom: 1.2rem; }
.grid-2c { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; white-space: pre-wrap; word-break: break-all; }
details summary { cursor: pointer; margin: .6rem 0; color: var(--primary); }

/* Módulo 4 — anexos e importação */
.attachments { border-top: 1px solid var(--line); padding-top: .7rem; margin-top: .4rem; }
.att-head { margin-bottom: .4rem; }
.att-row { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; align-items: center; padding: .3rem 0; }
.att-name { word-break: break-all; }
.att-add { margin-top: .4rem; cursor: pointer; }
.hidden-file { display: none; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 .8rem; }

/* Módulo 5 — white-label e plataforma */
.brand-logo { width: 2.2rem; height: 2.2rem; object-fit: contain; border-radius: 6px; }
.brand-preview { border: 1px dashed var(--line); border-radius: 10px; padding: .7rem; margin-bottom: .9rem; }
.color-input { width: 4rem; height: 2.4rem; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.pay-form { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
h4 { margin: 1rem 0 .5rem; }

/* ===== Celular / app instalável (1.1.0) ===== */
.mobile-top, .lbl-short { display: none; }
.install-slot:empty { display: none; }
.install-btn { width: 100%; justify-content: center; }
.auth-card .install-slot { margin-top: 1rem; }

@media (max-width: 860px) {
  body { -webkit-tap-highlight-color: transparent; }
  /* Campos com 16px: o iPhone não dá zoom ao tocar. */
  input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=date], select, textarea { font-size: 16px; }

  /* Barra superior compacta */
  .mobile-top {
    display: flex; align-items: center; gap: .4rem; position: sticky; top: 0; z-index: 30;
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: calc(.5rem + env(safe-area-inset-top)) calc(.8rem + env(safe-area-inset-right)) .5rem calc(.8rem + env(safe-area-inset-left));
  }
  .mobile-top .brand strong { font-size: .95rem; }
  .mobile-top .brand small { display: none; }
  .mobile-top .brand-logo, .mobile-top .brand-mark { width: 1.8rem; height: 1.8rem; font-size: 1.3rem; }
  .mobile-top .install-btn { width: auto; }
  .mobile-top .btn-icon { height: 2.4rem; }

  /* Menu vira barra de abas embaixo, como nos apps */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; width: auto; flex: none; z-index: 30;
    flex-direction: row; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-right: none; border-top: 1px solid var(--line); gap: 0;
  }
  .sidebar .brand, .sidebar .sidebar-foot { display: none; }
  .sidebar nav { flex-direction: row; width: 100%; gap: 0; }
  .sidebar nav a { flex: 1; flex-direction: column; align-items: center; gap: .1rem; padding: .45rem .1rem .4rem; border-radius: 0; font-size: .68rem; color: var(--muted); min-width: 0; }
  .sidebar nav a .ic { font-size: 1.25rem; line-height: 1; }
  .sidebar nav a .lbl { display: none; }
  .sidebar nav a .lbl-short { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .sidebar nav a.active { background: none; color: var(--primary); font-weight: 600; }

  .main { padding: 1rem calc(1rem + env(safe-area-inset-right)) calc(5.2rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left)); }
  #toast { left: 1rem; right: 1rem; bottom: calc(4.8rem + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }

  /* Cabeçalhos e abas */
  h2 { font-size: 1.2rem; }
  .page-head { gap: .5rem; }
  .page-head h2 { flex: 1 1 100%; order: -1; }
  .page-head .back { order: -2; flex: 1 1 100%; }
  .page-head .spacer { display: none; }
  .page-head .btn { padding: .4rem .7rem; font-size: .88rem; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: 0 0 auto; }
  .tab-exp { margin-left: 0; }
  .search { max-width: none; }

  /* Itens: toque confortável */
  .item-actions { justify-content: flex-start; flex-wrap: wrap; }
  .item-actions .btn-sm { padding: .45rem .8rem; font-size: .9rem; }
  .cards { grid-template-columns: 1fr; }

  /* Modais ocupam a tela inteira */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal { max-width: none; min-height: 100%; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal-head { position: sticky; top: 0; background: var(--panel); z-index: 1; padding-top: calc(1rem + env(safe-area-inset-top)); }
  .kv-actions .btn-sm { padding: .45rem .8rem; }

  .table th, .table td { padding: .45rem .5rem; }
  .grid2 { grid-template-columns: 1fr; }
  .auth { padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom)); justify-content: flex-start; }
  .auth-card { padding: 1.4rem; }
}
/* App instalado (janela própria): sem margens do navegador */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
