/* Central de Operação — design inspirado nos princípios da Apple:
   clareza, deferência ao conteúdo, profundidade sutil, tipografia do sistema. */

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --tile: #f5f5f7;
  --tile-hover: #ececf0;
  --text: #1d1d1f;
  --text2: #424245;
  --text3: #86868b;
  --line: rgba(0, 0, 0, .08);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #248a3d;
  --green-soft: #e4f6e8;
  --red: #d70015;
  --orange: #c93400;
  --bar: rgba(245, 245, 247, .72);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 30px rgba(0, 0, 0, .05);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .25);
  --toast-bg: rgba(29, 29, 31, .92);
  --toast-fg: #f5f5f7;
  --field: #ffffff;
  --field-line: #d2d2d7;
  --ring: rgba(0, 113, 227, .35);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --tile: #2c2c2e;
    --tile-hover: #3a3a3c;
    --text: #f5f5f7;
    --text2: #d1d1d6;
    --text3: #8e8e93;
    --line: rgba(255, 255, 255, .1);
    --blue: #0a84ff;
    --blue-hover: #409cff;
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, .16);
    --red: #ff453a;
    --orange: #ff9f0a;
    --bar: rgba(0, 0, 0, .66);
    --shadow: 0 0 0 .5px rgba(255, 255, 255, .06);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .7);
    --toast-bg: rgba(245, 245, 247, .94);
    --toast-fg: #1d1d1f;
    --field: #2c2c2e;
    --field-line: #48484a;
    --ring: rgba(10, 132, 255, .45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; flex: none; display: block; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: .5px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar-in {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  min-height: 56px; display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; }
.logo {
  width: 24px; height: 24px; border-radius: 7px; background: var(--blue);
  position: relative; display: inline-block;
}
.logo::before, .logo::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 2px; background: #fff;
}
.logo::before { top: 7px; }
.logo::after { top: 13px; right: 10px; opacity: .8; }

.search {
  margin-left: auto; position: relative; display: flex; align-items: center;
  width: min(280px, 38vw);
}
.search .ico { position: absolute; left: 10px; color: var(--text3); width: 16px; height: 16px; pointer-events: none; }
.search input {
  width: 100%; height: 34px; border: 0; border-radius: 10px;
  background: rgba(120, 120, 128, .12); padding: 0 34px 0 32px; font-size: 14px;
}
.search input::placeholder { color: var(--text3); }
.search input:focus { outline: none; background: var(--field); box-shadow: 0 0 0 3px var(--ring); }
.search kbd {
  position: absolute; right: 8px; font: 500 11px var(--font); color: var(--text3);
  border: .5px solid var(--line); border-radius: 5px; padding: 0 5px; line-height: 17px;
}
.search input:focus ~ kbd { display: none; }

.sync { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text3); white-space: nowrap; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.sync[data-state="ok"] .dot { background: #30d158; }
.sync[data-state="saving"] .dot { background: #ff9f0a; animation: pulse 1s ease-in-out infinite; }
.sync[data-state="error"] .dot { background: #ff453a; }
.sync[data-state="local"] .dot { background: #ff9f0a; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 16px; border: 0; border-radius: 980px;
  background: rgba(120, 120, 128, .14); color: var(--text); font-weight: 500; font-size: 14px;
  transition: background .15s, transform .1s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: rgba(120, 120, 128, .22); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; padding: 0 10px; }
.btn.ghost:hover { background: rgba(215, 0, 21, .08); }
.btn.big { height: 44px; padding: 0 26px; font-size: 16px; }
.btn.full { width: 100%; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .ico { width: 16px; height: 16px; }

.icon-btn {
  width: 30px; height: 30px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(120, 120, 128, .16); color: var(--text3);
}
.icon-btn:hover { background: rgba(120, 120, 128, .26); color: var(--text); }
.icon-btn .ico { width: 14px; height: 14px; }

.link {
  border: 0; background: none; padding: 0; color: var(--blue); font-size: 13px;
}
.link:hover { text-decoration: underline; }

/* ---------- Banner ---------- */
.banner {
  max-width: 1180px; margin: 14px auto 0; padding: 12px 16px; border-radius: 14px;
  background: rgba(255, 159, 10, .14); color: var(--text2); font-size: 13.5px;
  width: calc(100% - 40px);
}
.banner strong { color: var(--text); font-weight: 600; }

/* ---------- Página ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 60px; }
.head { padding: 34px 0 22px; }
.head h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; }
.sub { margin: 8px 0 0; color: var(--text3); font-size: 17px; }

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr));
  align-items: start;
}

.card {
  background: var(--card); border-radius: 22px; padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.card-title { flex: 1 1 200px; min-width: 0; }
.card-title h2 {
  margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2;
  overflow-wrap: anywhere;
}
.meta { margin: 6px 0 0; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text3); flex-wrap: wrap; }
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 980px; font-size: 11.5px; font-weight: 600;
  background: rgba(0, 113, 227, .12); color: var(--blue);
}
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.group { display: flex; flex-direction: column; gap: 8px; }
.group > h3 {
  margin: 0 0 0 4px; font-size: 12px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .06em;
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .pair { grid-template-columns: 1fr; } }

/* ---------- Campo clicável (copia ao clicar) ---------- */
.tile-wrap { position: relative; min-width: 0; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; min-height: 62px; text-align: left; border: 0; border-radius: 14px;
  background: var(--tile); padding: 11px 44px 11px 14px; position: relative;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover { background: var(--tile-hover); }
.tile:active { transform: scale(.985); }
.tile-label { font-size: 12px; font-weight: 500; color: var(--text3); }
.tile-value {
  font-size: 15px; font-weight: 500; color: var(--text); width: 100%;
  overflow-wrap: anywhere; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.tile.is-code .tile-value {
  font: 400 12px/1.5 var(--mono); white-space: pre-wrap; -webkit-line-clamp: 4; line-clamp: 4; color: var(--text2);
}
.tile.is-empty .tile-value { color: var(--text3); font-weight: 400; }
.tile-hint {
  position: absolute; top: 11px; right: 14px; font-size: 12px; font-weight: 500; line-height: 16px;
  color: var(--blue); opacity: 0; transition: opacity .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.tile-hint .todo, .tile-hint .done { display: inline-flex; align-items: center; gap: 4px; }
.tile:hover .tile-hint, .tile:focus-visible .tile-hint { opacity: 1; }
/* Celular: sem hover, o ícone fica sempre visível (só o ícone, para não apertar o valor). */
@media (hover: none) {
  .tile-hint { opacity: .8; }
  .tile-hint .txt { display: none; }
  .tile.copied .tile-hint .txt { display: inline; }
}
.tile .tile-hint .ico { width: 13px; height: 13px; }
.tile .done { display: none; }
.tile.copied { background: var(--green-soft); }
.tile.copied .tile-hint { opacity: 1; color: var(--green); }
.tile.copied .tile-hint .todo { display: none; }
.tile.copied .tile-hint .done { display: inline-flex; }
.tile.is-empty .tile-hint { color: var(--text3); }

.tile-open {
  position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text3); text-decoration: none;
  background: transparent; transition: background .15s, color .15s;
}
.tile-open:hover { background: rgba(120, 120, 128, .2); color: var(--blue); }
.tile-open .ico { width: 15px; height: 15px; }

/* ---------- Vazio ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--text3); }
.empty h2 { margin: 0 0 8px; color: var(--text); font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.empty p { margin: 0 auto 22px; max-width: 460px; font-size: 16px; }

.foot { text-align: center; padding: 0 20px 40px; color: var(--text3); display: flex; gap: 10px; justify-content: center; align-items: center; }

/* ---------- Diálogos ---------- */
dialog {
  border: 0; padding: 0; background: var(--card); color: var(--text);
  border-radius: 26px; width: min(640px, calc(100% - 24px)); max-height: min(92dvh, 900px);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
dialog.small { width: min(380px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(0, 0, 0, .38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }

#edForm { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 6px; }
.dlg-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.dlg-body { padding: 8px 22px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; overscroll-behavior: contain; }
.dlg-body h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }
.dlg-foot {
  display: flex; align-items: center; gap: 8px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  border-top: .5px solid var(--line); background: var(--card);
}
.spacer { flex: 1; }

.fill { background: var(--tile); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.lbl, .lbl-s, .field label { font-size: 13px; font-weight: 500; color: var(--text2); }
.lbl-s { display: block; margin-bottom: 6px; }
.opt { color: var(--text3); font-weight: 400; }
.reuse { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.row { display: flex; gap: 12px; }
.grow { flex: 1 1 0; }
@media (max-width: 520px) { .row { flex-direction: column; gap: 0; } }

input[type="text"], input[type="password"], select, textarea {
  width: 100%; border: 1px solid var(--field-line); background: var(--field); border-radius: 12px;
  padding: 10px 12px; font-size: 15px; min-height: 42px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.45; }
textarea.mono { font: 400 12.5px/1.5 var(--mono); }
.fill textarea { background: var(--field); font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--ring); }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text3) 50%), linear-gradient(135deg, var(--text3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.hint { margin: 0; font-size: 12.5px; color: var(--text3); }
.hint.warn { color: var(--orange); }
.hint.ok { color: var(--green); }
.hint.err { color: var(--red); }
.inline-actions { display: flex; gap: 14px; }

.seg { display: inline-flex; background: rgba(120, 120, 128, .14); border-radius: 11px; padding: 2px; gap: 2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  padding: 6px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--text2); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg input:checked + label { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
@media (prefers-color-scheme: dark) { .seg input:checked + label { background: #636366; } }
.seg input:focus-visible + label { outline: 3px solid var(--ring); }

/* acesso */
.lock-in { padding: 30px 26px 26px; display: flex; flex-direction: column; align-items: stretch; gap: 12px; text-align: center; }
.lock-ico { width: 52px; height: 52px; border-radius: 15px; background: rgba(0, 113, 227, .12); color: var(--blue); display: grid; place-items: center; margin: 0 auto 4px; }
.lock-ico .ico { width: 26px; height: 26px; }
.lock-in h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.lock-in .muted { margin: 0 0 6px; color: var(--text3); }
.lock-in input { text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translate(-50%, 0);
  z-index: 100; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  padding: 11px 18px 11px 14px; border-radius: 980px; font-size: 14px; font-weight: 500;
  background: var(--toast-bg); color: var(--toast-fg);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
  animation: toast-in .25s cubic-bezier(.2, .8, .2, 1);
}
.toast.out { opacity: 0; transform: translate(-50%, 8px); transition: opacity .25s, transform .25s; }
.toast .ok { width: 18px; height: 18px; color: #30d158; }
.toast.err .ok { display: none; }
.toast-act { border: 0; background: none; color: #64b5ff; font-weight: 600; padding: 0 0 0 6px; }
@media (prefers-color-scheme: dark) { .toast-act { color: #0071e3; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

@media (max-width: 720px) {
  .brand-name, .sync span, .search kbd { display: none; }
  .bar-in { gap: 10px; padding: 0 14px; }
  .search { width: auto; flex: 1; margin-left: 0; }
  .btn.primary span { display: none; }
  #newBtn { width: 34px; padding: 0; }
  .head { padding-top: 24px; }
  .head h1 { font-size: 28px; }
  .wrap { padding: 0 14px 60px; }
  .card { padding: 16px; border-radius: 20px; }
  .banner { width: calc(100% - 28px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
