/* Posta Takip – arayüz */
:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2758ae;
  --brand-2: #1f4a94;
  --brand-soft: #e6edf8;
  --brand-gray: #343c45;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --green: #15803d;
  --green-soft: #dcfce7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --violet: #6d28d9;
  --violet-soft: #ede9fe;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ic { flex: none; display: inline-block; vertical-align: middle; }

.boot { display: flex; align-items: center; justify-content: center; min-height: 100vh; color: var(--muted); }

/* ---------- üst çubuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  min-height: calc(var(--safe-top) + 52px);
  background: rgba(242, 244, 247, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}
.tb-title { font-weight: 650; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.tb-left { justify-self: start; }
.tb-right { justify-self: end; display: flex; gap: 4px; }
.tb-back { display: inline-flex; align-items: center; gap: 0; text-decoration: none; color: var(--brand); font-size: 16px; padding: 6px 4px; margin-left: -6px; }
.tb-btn { border: 0; background: transparent; color: var(--brand); width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.tb-btn:active { background: var(--brand-soft); }

.page { padding: 12px 16px calc(var(--safe-bottom) + 96px); max-width: 720px; margin: 0 auto; }
.page.no-tab { padding-bottom: calc(var(--safe-bottom) + 24px); }

/* ---------- alt sekmeler ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tab { position: relative; flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; text-decoration: none; color: #8a94a6; font-size: 11px; font-weight: 600; }
.tab.on { color: var(--brand); }
.tab-badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* ---------- kart, liste ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border: 1px solid rgba(226, 232, 240, 0.9); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.card-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin: 18px 4px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.item { display: block; position: relative; text-decoration: none; color: inherit; background: var(--card); border: 1px solid rgba(226, 232, 240, 0.9); border-radius: 14px; padding: 12px 14px 12px 16px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.item:active { background: #f8fafc; }
.item.is-new::before { content: ""; position: absolute; left: 6px; top: 19px; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.item-sender { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.is-new .item-sender { font-weight: 750; }
.item-date { color: var(--muted); font-size: 13px; flex: none; }
.item-subject { color: var(--ink-2); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); white-space: nowrap; }
.b-red { background: var(--red-soft); color: #b91c1c; }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.b-gray { background: #f1f5f9; color: #475569; }

.search { position: relative; margin-bottom: 10px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 11px 12px 11px 38px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px; -webkit-appearance: none; appearance: none; }

.segmented { display: flex; background: #e4e7ec; border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.segmented button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.segmented button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }
.seg-count:not(:empty) { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 9px; background: var(--brand); color: #fff; }
.segmented button:not(.on) .seg-count:not(:empty) { background: #94a3b8; }

.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; text-decoration: none; }
.alert-amber { background: var(--amber-soft); color: #78350f; }
.alert-red { background: var(--red-soft); color: #7f1d1d; }
.alert-blue { background: var(--blue-soft); color: #1e3a8a; }
.alert .ic { margin-top: 1px; }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .ic { color: #cbd5e1; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink-2); font-size: 17px; margin-bottom: 4px; }

.loading { display: flex; justify-content: center; padding: 32px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin 0.8s linear infinite; flex: none; }
.spin-s { width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- düğmeler, form ---------- */
.btn { -webkit-appearance: none; appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 48px; font-size: 16px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; transition: transform 0.06s ease, opacity 0.15s; line-height: 1.2; text-align: center; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-2); }
.btn-secondary { background: var(--brand-soft); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--red); }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 17px; border-radius: 14px; }
.btn-sm { min-height: 38px; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-row > .btn { flex: 1; }
.stack > * + * { margin-top: 8px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; background: #fff; -webkit-appearance: none; appearance: none; min-height: 46px; }
.field select { background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input[type="date"] { min-height: 46px; }
.check { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: var(--red); font-size: 14px; margin-top: 10px; }

/* ---------- giriş ---------- */
.login { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-top) + 48px) 20px 32px; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-logo { display: block; width: 250px; max-width: 72vw; height: auto; margin: 0 auto 18px; }
.login h1 { font-size: 24px; margin: 0 0 4px; color: var(--brand-gray); }

/* ---------- yükleme ---------- */
.hero { text-align: center; padding: 24px 18px 18px; }
.hero-icon { width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 22px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.hero h2 { margin: 0 0 6px; font-size: 21px; }
.hero p { margin: 0 0 18px; color: var(--muted); }
.hero .btn + .btn { margin-top: 10px; }
.tips { display: flex; gap: 10px; color: var(--muted); font-size: 14px; padding: 4px 6px; }
.tips .ic { color: var(--amber); margin-top: 1px; }

.pages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pg { position: relative; aspect-ratio: 0.72; border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }
.pg-img { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: #fff; cursor: pointer; }
.pg-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.pg-pdf { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--brand); padding: 8px; text-align: center; }
.pg-pdf b { font-size: 14px; }
.pg-pdf span { font-size: 12px; color: var(--ink-2); }
.pg-pdf small { font-size: 10px; color: var(--muted); word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pg-no { position: absolute; top: 6px; left: 6px; background: rgba(15, 23, 42, 0.75); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 8px; }
.pg-tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(15, 23, 42, 0.55)); }
.pg-tools button { width: 30px; height: 30px; border-radius: 9px; border: 0; background: rgba(255, 255, 255, 0.92); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.pg-tools button[disabled] { opacity: 0.35; }
.pg-tools button[data-act="del-page"] { color: var(--red); }
.pg-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed #cbd5e1; background: transparent; color: var(--brand); font-weight: 650; font-size: 13px; cursor: pointer; box-shadow: none; }

.success { text-align: center; padding: 28px 18px 18px; }
.success-icon { width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; }
.success h2 { margin: 0 0 6px; }
.success p { color: var(--muted); margin: 0 0 18px; }
.success .btn + .btn, .success .btn + a.btn { margin-top: 8px; }

/* ---------- detay ---------- */
.head-card { padding: 16px 16px 14px; }
.head-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.head-sender { font-size: 22px; line-height: 1.2; margin: 0 0 4px; }
.head-subject { font-size: 16px; color: var(--ink-2); }
.head-meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.deadline { display: flex; gap: 14px; align-items: center; border-left: 5px solid var(--blue); }
.deadline.d-red { border-left-color: var(--red); }
.deadline.d-amber { border-left-color: #d97706; }
.deadline.d-done { border-left-color: var(--green); }
.deadline-date { text-align: center; flex: none; min-width: 64px; }
.deadline-date .dd { font-size: 28px; font-weight: 800; line-height: 1; }
.deadline-date .mm { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.deadline-text b { display: block; font-size: 16px; }
.deadline-text div { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.summary { margin: 0; font-size: 16px; line-height: 1.5; }
.todos { margin: 12px 0 0; padding: 0; list-style: none; }
.todos li { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.todos li::before { content: ""; flex: none; width: 16px; height: 16px; border: 2px solid #94a3b8; border-radius: 5px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; margin: 0; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.ai-wait { display: flex; gap: 12px; align-items: center; background: var(--violet-soft); border-color: #ddd6fe; }
.actions { margin: 4px 0 8px; }
.pdf-pages { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.pdf-pages canvas { width: 100%; height: auto; border-radius: 6px; background: #fff; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12); }

/* ---------- ayarlar, kullanıcılar ---------- */
.profile { display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.avatar.post { background: #0f766e; }
.avatar.off { background: #94a3b8; }
.link-card { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.link-card > div { flex: 1; }
.link-card .ic:last-child { color: #94a3b8; }
.install { display: flex; gap: 12px; align-items: flex-start; background: #fffbeb; border-color: #fde68a; }
.install .ic { color: var(--amber); }
.status-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.status-row:first-child { border-top: 0; padding-top: 0; }
.status-row > span:first-child { color: var(--muted); flex: none; }
.status-row > span:last-child { text-align: right; word-break: break-word; }
.ok-t { color: var(--green); font-weight: 650; }
.bad-t { color: var(--amber); font-weight: 650; }
.user-row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 1px solid rgba(226, 232, 240, 0.9); background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.user-row .u-text { flex: 1; min-width: 0; }
.user-row b { display: block; }
.version { text-align: center; margin: 18px 0 8px; }
.conn-state { font-size: 14px; margin: -2px 0 10px; }
details.adv { margin: 4px 0 8px; }
details.adv summary { cursor: pointer; color: var(--brand); font-weight: 650; font-size: 14px; padding: 6px 0 10px; }
.cron-row > span:last-child { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; }
code.path { font-size: 12px; background: #f1f5f9; padding: 3px 6px; border-radius: 6px; word-break: break-all; text-align: left; }

/* ---------- katman, bildirim ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.overlay-box { background: #fff; border-radius: 18px; padding: 22px 22px 18px; min-width: 220px; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25); }
.overlay-text { font-weight: 650; text-align: center; }
.progress { width: 100%; height: 6px; background: var(--brand-soft); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 84px); transform: translateX(-50%); z-index: 90; background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 550; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3); animation: toastIn 0.2s ease; transition: opacity 0.3s; }
.toast.error { background: #991b1b; }
.toast.ok { background: #166534; }
.toast.out { opacity: 0; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- kırpma ekranı ---------- */
.ed { position: fixed; inset: 0; z-index: 60; background: #0b1220; color: #fff; display: flex; flex-direction: column; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); -webkit-user-select: none; user-select: none; }
.ed-top { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; min-height: 50px; }
.ed-title { font-weight: 650; }
.ed-link { border: 0; background: transparent; color: #93c5fd; font-size: 16px; font-weight: 600; padding: 10px; cursor: pointer; }
.ed-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.ed-img { position: absolute; display: block; }
.ed-svg { position: absolute; left: 0; top: 0; touch-action: none; }
.ed-shade { fill: rgba(2, 6, 23, 0.55); }
.ed-poly { fill: rgba(96, 165, 250, 0.12); stroke: #60a5fa; stroke-width: 2; }
.ed-h { fill: rgba(255, 255, 255, 0.95); stroke: #2563eb; stroke-width: 3; }
.ed-h.on { fill: #2563eb; stroke: #fff; }
.ed-loupe { position: absolute; top: 10px; width: 124px; height: 124px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); pointer-events: none; background: #000; }
.ed-hint { text-align: center; font-size: 13px; color: #cbd5e1; padding: 6px 12px 0; }
.ed-filters { display: flex; justify-content: center; gap: 8px; padding: 10px 12px 4px; }
.ed-filters button { border: 0; border-radius: 999px; padding: 8px 16px; background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 650; font-size: 14px; cursor: pointer; }
.ed-filters button.on { background: #fff; color: #0f172a; }
.ed-bottom { display: flex; gap: 10px; padding: 10px 12px 12px; align-items: center; }
.ed-tool { border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; border-radius: 12px; min-width: 56px; height: 50px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; font-weight: 600; cursor: pointer; padding: 0 8px; }
.ed-ok { flex: 1; min-height: 50px; }

@media (min-width: 700px) {
  .pages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
