*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: #1a3a8f; }
:root {
  --bg: #f0f4f8; --surface: #fff; --border: #cfdce8;
  --accent: #1a3a8f; --accent2: #28b5a0; --accent-light: #ddeeff;
  --text: #1a1a2e; --muted: #5a7080;
  --header-h: 170px;
  --sticky-header-h: 170px;
  --tabs-h: 38px;
  --footer-h: 32px;
}
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100dvh; padding-top: env(safe-area-inset-top); }

/* ── PULL AREA ── */
#pullArea { padding-top: 20px;position: fixed; top: 0; left: 0; right: 0; height: 550px; z-index: 99; background: #1a3a8f; display: flex; align-items: flex-start; justify-content: center; gap: 0.5rem; color: rgba(255,255,255,0.65); font-family: 'DM Serif Display', serif; font-size: 0.85rem; }

/* ── STICKY TOP ── */
.sticky-top { position: sticky; top: 0; z-index: 100; background: var(--accent); height: var(--sticky-header-h); /* box-shadow: 0 2px 14px rgba(0,0,0,0.18); */}
header { padding: 0.9rem 1rem 0.35rem; display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; }
.header-titles { flex: 1; text-align: center; }
header h1 { font-family: 'DM Serif Display', serif; font-size: clamp(1.1rem,5vw,1.7rem); color: #fff; line-height: 1.2; }
header p { color: rgba(255,255,255,0.6); font-size: 0.72rem; margin-top: 0.1rem; }
.desk-wrap{
  margin:0 auto; max-width: 760px;
}
.search-wrap { margin:  0.45rem 1rem 0; background: #fff; border-radius: 12px; padding: 0.6rem 1rem; display: flex; align-items: center; gap: 0.6rem; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.search-icon { color: var(--muted); flex-shrink: 0; }
#searchInput { border: none; outline: none; font-family: 'DM Sans', sans-serif; font-size: 1rem; color: var(--text); background: transparent; flex: 1; min-width: 0; }
#searchInput::placeholder { color: #aab8c2; }
#clearBtn { display: none; background: none; border: none; cursor: pointer; padding: 2px; line-height: 0; flex-shrink: 0; }

.filters-wrap { padding: 0.45rem 1rem 0.55rem; display: flex; flex-direction: column; gap: 0.4rem; }
.sel-row { display: flex; gap: 0.4rem; }
.filters-wrap select { flex: 1; min-width: 0; padding: 0.5rem 2rem 0.5rem 0.8rem; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.4); background: rgba(255,255,255,0.12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.6rem center; color: #fff; font-family: 'DM Sans', sans-serif; font-size: 0.82rem; font-weight: 500; appearance: none; -webkit-appearance: none; cursor: pointer; }
.filters-wrap select option { background: #1a3a8f; color: #fff; }
#subSelect { display: none; }

/* ── TABS ── */
/*.tabs { max-width: 760px; margin: 0 auto; display: flex; border-bottom: 2px solid var(--border); background: var(--bg); position: sticky; top: var(--header-h); z-index: 100; height: calc(var(--tabs-h) - 2px); }*/
.tabs {border-bottom: 2px solid var(--border); background: var(--bg); position: sticky; top: var(--header-h); z-index: 101; height: calc(var(--tabs-h) - 2px); }
.tabs-dsk{
   max-width: 760px; margin: 0 auto;
   display: flex; 
}
.tab { flex: 1; padding: 0.55rem 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); background: none; border: none; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-badge { display: inline-block; background: var(--accent-light); color: var(--accent); font-size: 0.65rem; border-radius: 999px; padding: 0 5px; margin-left: 3px; }

/* ── LAYOUT ── */
.layout { display: flex; margin: 0 auto; /*padding: 0.75rem 0 5rem;*/position: relative; background: var(--bg);z-index: 100; height: calc(100dvh -  var(--sticky-header-h) - var(--tabs-h) - var(--footer-h)); overflow: auto; }
.alpha-bar { position: sticky; top:  0px; height:calc(100dvh -  var(--sticky-header-h) - var(--tabs-h) - var(--footer-h)); width: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; flex-shrink: 0; padding: 0.5rem 0; z-index: 50; order: 2; }
.alpha-bar a { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; line-height: 1; padding: 2px 3px; border-radius: 4px; transition: background 0.12s, color 0.12s; display: block; width: 22px; text-align: center; }
.alpha-bar a:hover, .alpha-bar a.active { background: var(--accent); color: #fff; }
.alpha-bar a.disabled { color: #bcd0e0; pointer-events: none; }

.content { flex: 1; padding: 0.75rem 0.25rem 0.75rem 0.75rem; min-width: 0; order: 1; max-width: 760px; margin: 0 auto; }
.count { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; padding-left: 0.25rem; }
.letter-header { font-family: 'DM Serif Display', serif; font-size: 1.1rem; color: var(--accent); padding: 0.6rem 0 0.3rem 0.25rem; border-bottom: 2px solid var(--accent-light); margin-bottom: 0.4rem; margin-top: 0.6rem; }
.letter-header:first-child { margin-top: 0; }
.other-cats-header { font-size: 0.75rem; font-weight: 600; color: var(--muted); padding: 0.5rem 0.25rem 0.4rem; border-bottom: 1px dashed var(--border); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
#directory{
  padding-bottom:25px
}
/* ── CARD ── */
.card { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 0.75rem 0.9rem; display: flex; align-items: flex-start; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.5rem; animation: fadeIn 0.25s ease both; position: relative; }
.card.fav { border-left: 3px solid var(--accent); }
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:translateY(0)} }
.card-info { flex: 1; min-width: 0; overflow: hidden; }
.card-name { font-weight: 600; font-size: clamp(1rem,3.5vw,0.93rem); color: var(--text); word-break: break-word; line-height: 1.3; }
.card-dept { font-size: clamp(0.8rem,2.8vw,0.76rem); color: var(--muted); margin-top: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-persona { font-size: 0.76rem; color: var(--accent2); font-weight: 500; margin-top: 0.1rem; text-overflow: ellipsis; overflow: hidden;white-space: nowrap;}
.card-tags { display: flex; flex-wrap: nowrap; gap: 3px; min-width: 0; overflow: hidden; width: 100%; margin-top: 0rem; }
.card-tag { display: inline-block; background: var(--accent-light); color: var(--accent); font-size: 0.67rem; font-weight: 500; border-radius: 999px; padding: 0.1rem 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
.card-tag.sub { background: #e0f5f2; color: #1a7a6e; }
.card-obs { font-size: 0.68rem; color: var(--muted); margin-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; }
.card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; flex-shrink: 0; max-width: 44%; }
.card-number { font-size: clamp(0.72rem,3vw,0.85rem); font-weight: 600; color: var(--accent); text-align: right; word-break: break-word; line-height: 1.3; }
.btn-row { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.call-btn, .wa-btn, .mail-btn, .fav-btn { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer; text-decoration: none; transition: background 0.15s, transform 0.15s; flex-shrink: 0; }
.call-btn { background: var(--accent); color: #fff; }
.call-btn:hover { background: #0f2460; transform: scale(1.08); }
.wa-btn { background: #25d366; color: #fff; }
.wa-btn:hover { background: #1da851; transform: scale(1.08); }
.mail-btn { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.mail-btn:hover { background: var(--accent-light); transform: scale(1.08); }
.fav-btn { background: transparent; color: var(--accent); }
.fav-btn.active { color: var(--accent); }
.empty-rest{ border: none; padding: 16px 12px; background: var(--accent-light); border-radius: 12px; text-align: center; color: var(--accent); font-weight: 600; font-size: clamp(1rem, 3.5vw, 0.93rem); word-break: break-word; margin: 16px 0; }

/* ── TOAST ── */
#toast { position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1a3a8f; color: #fff; padding: 0.5rem 1.2rem; border-radius: 999px; font-size: 0.82rem; opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; z-index: 999; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); display: none; }

/* ── INSTALL BANNER ── */
#installBanner { position: fixed; bottom: calc(50px + env(safe-area-inset-bottom) + 0.6rem); left: 1rem; right: 1rem; z-index: 200; background: #fff; border-radius: 16px; box-shadow: 0 4px 28px rgba(0,0,0,0.22); padding: 0.9rem 0.85rem 0.9rem 1rem; display: none; align-items: flex-start; gap: 0.75rem; }
#installBanner.show { display: flex; animation: slideUp 0.35s ease; }
.ib-text { flex: 1; min-width: 0; }
.ib-title { font-weight: 700; font-size: 0.88rem; color: var(--text); margin-bottom: 0.25rem; }
.ib-desc { font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.ib-desc strong { color: var(--text); font-weight: 600; }
.ib-close { background: none; border: none; cursor: pointer; color: #aab8c2; padding: 0; font-size: 1.1rem; line-height: 1; flex-shrink: 0; margin-top: 1px; }
.ib-arrow { display: none; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 7px solid #fff; }
@keyframes slideUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }

/* ── CALL POPUP ── */
#callPopup { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.45); align-items: flex-end; justify-content: center; }
#callPopup.show { display: flex; }
#callSheet { background: #fff; border-radius: 20px 20px 0 0; width: 100%; max-width: 480px; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); animation: slideUp 0.3s ease; }
.cs-handle { width: 36px; height: 4px; background: #ddd; border-radius: 2px; margin: 0 auto 0.9rem; }
.cs-title { font-weight: 700; font-size: 0.95rem; color: var(--text); margin-bottom: 0.75rem; padding: 0 0.5rem; }
.cs-num { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0.5rem; border-radius: 10px; cursor: pointer; text-decoration: none; color: var(--text); transition: background 0.12s; }
.cs-num:hover, .cs-num:active { background: var(--accent-light); }
.cs-num-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cs-num-val { font-weight: 600; font-size: 0.9rem; }
.cs-num-tag { font-size: 0.7rem; color: var(--muted); margin-top: 1px; }
.cs-cancel { width: 100%; margin-top: 0.5rem; padding: 0.75rem; border: none; border-radius: 12px; background: var(--bg); color: var(--muted); font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }

/* ── ADD CONTACT FORM ── */
#addFormOverlay { display: none; position: fixed; inset: 0; z-index: 400; background: var(--bg); flex-direction: column; overflow-y: auto; }
#addFormOverlay.show { display: flex; }
.af-header { background: var(--accent); color: #fff; padding: calc(0.9rem + env(safe-area-inset-top)) 1rem 0.9rem; display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.af-header h2 { flex: 1; font-family: 'DM Serif Display', serif; font-size: 1.1rem; font-weight: 400; }
.af-close { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; line-height: 0; opacity: 0.85; flex-shrink: 0; }
.af-body { flex: 1; padding: 1.25rem 1rem calc(2rem + env(safe-area-inset-bottom)); max-width: 540px; margin: 0 auto; width: 100%; }
.af-notice { background: var(--accent-light); color: var(--accent); font-size: 0.78rem; border-radius: 10px; padding: 0.65rem 0.85rem; margin-bottom: 1.25rem; line-height: 1.5; }
.af-field { margin-bottom: 0.9rem; }
.af-field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; }
.af-field input { width: 100%; padding: 0.6rem 0.8rem; border: 1.5px solid var(--border); border-radius: 10px; font-family: 'DM Sans', sans-serif; font-size: 0.9rem; color: var(--text); background: var(--surface); outline: none; transition: border-color 0.15s; }
.af-field input:focus { border-color: var(--accent); }
.af-field input::placeholder { color: #aab8c2; }
.af-field select { width: 100%; padding: 0.6rem 2rem 0.6rem 0.8rem; border: 1.5px solid var(--border); border-radius: 10px; font-family: 'DM Sans', sans-serif; font-size: 0.9rem; color: var(--text); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a7080' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.6rem center; appearance: none; -webkit-appearance: none; outline: none; transition: border-color 0.15s; }
.af-field select:focus { border-color: var(--accent); }
.af-submit { width: 100%; padding: 0.85rem; background: var(--accent); color: #fff; border: none; border-radius: 12px; font-family: 'DM Sans', sans-serif; font-size: 0.95rem; font-weight: 600; cursor: pointer; margin-top: 0.75rem; transition: background 0.15s; }
.af-submit:hover { background: #0f2460; }
.af-preview { margin: 1.5rem 0 1rem; }
.af-preview-title { font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.af-preview-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 0.75rem 0.9rem; display: flex; align-items: flex-start; gap: 0.75rem; min-height: 52px; }
#favActions { padding: 0.5rem 0 1.5rem; display: flex; gap: 0.6rem; }
.fav-action-btn { flex: 1; padding: 0.65rem 0.5rem; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); color: var(--muted); font-family: 'DM Sans', sans-serif; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.fav-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.fav-action-import { border-style: dashed; }
.del-btn { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #f5c6cb; background: #fff0f0; color: #c0392b; cursor: pointer; flex-shrink: 0; transition: background 0.15s, transform 0.15s; }
.del-btn:hover { background: #f5c6cb; transform: scale(1.08); }
.card-pendent { display: inline-block; background: #fff3cd; color: #856404; font-size: 0.62rem; font-weight: 700; border-radius: 999px; padding: 0.05rem 0.45rem; margin-left: 5px; vertical-align: middle; letter-spacing: 0.02em; }
.tab-add { flex: 0 0 auto; padding: 0.55rem 1rem; color: #fff !important; background: #2196f3 !important; border-bottom-color: transparent !important; border-radius: 0; }
.tab-add:hover { opacity: 0.88; }
.tabs::before {
    position: absolute;
    height: 14px;
    content: "";
    width: 100%;
    bottom: -16px;
    left: 0px;
    background: linear-gradient(180deg, #f0f4f8, #f0f4f800);
}
/* ── FOOTER ── */
footer { height: var(--footer-h); fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: var(--accent); color: rgba(255,255,255,0.65); text-align: center; font-size: 0.72rem; padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom)); letter-spacing: 0.03em; box-shadow: 0 -2px 10px rgba(0,0,0,0.15); display: flex; align-items: center; justify-content: center; gap: 1rem;     margin-top: 2px;}
footer span { color: rgba(255,255,255,0.35); }
footer .upd { font-size: 0.65rem; color: rgba(255,255,255,0.4); }
/*
.tabs::before {
    display: block;
    content: "";
    width: 50dvw;
    height: 40px;
    background: var(--bg);
    position: absolute;
    left: -50dvw;
}
.tabs::after {
    display: block;
    content: "";
    width: 50dvw;
    height: 40px;
    background: var(--bg);
    position: absolute;
    right: -50dvw;
}*/