/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a5276;
  --primary-dark: #154360;
  --primary-light: #d6eaf8;
  --accent: #2980b9;
  --text: #1a1a2e;
  --text-sub: #5d6d7e;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dce3ea;
  --amber: #f39c12;
  --amber-bg: #fef9e7;
  --red: #c0392b;
  --green: #27ae60;
  --tab-height: 60px;
  --header-height: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 20px rgba(0,0,0,0.08);
}

#banners { flex-shrink: 0; }

#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* ── Banners ─────────────────────────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
}

.banner-update {
  background: var(--amber-bg);
  color: #7d4e00;
  border-bottom: 1px solid var(--amber);
}

.banner-offline {
  background: #fdecea;
  color: var(--red);
  border-bottom: 1px solid #f1948a;
}

.banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

.banner-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.banner-btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: white;
}

/* ── Tab Bar ─────────────────────────────────────────────────────────────── */
#tab-bar {
  display: flex;
  height: var(--tab-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  padding: 8px 0;
}

.tab-btn .tab-icon { font-size: 20px; }
.tab-btn.active { color: var(--primary); }

/* ── List Header (sticky search + sort) ──────────────────────────────────── */
.list-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.search-input:focus { border-color: var(--primary); }

.sort-toggle {
  display: flex;
  gap: 6px;
}

.sort-btn {
  flex: 1;
  padding: 7px 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.sort-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Item List ───────────────────────────────────────────────────────────── */
.item-list {
  padding: 0;
}

.list-item {
  min-height: 60px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  -webkit-tap-highlight-color: transparent;
}

.list-item:active { background: var(--primary-light); }

.item-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.item-sub {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.3;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-sub);
  font-size: 15px;
}

/* ── View Title ──────────────────────────────────────────────────────────── */
.view-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  padding: 4px 0;
}

/* ── Detail View ─────────────────────────────────────────────────────────── */
.detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.back-btn:active { background: rgba(255,255,255,0.35); }

.detail-title {
  color: white;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-body {
  padding: 20px 16px 120px; /* room for action bar */
}

.detail-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  line-height: 1.2;
}

.detail-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-section:last-child { border-bottom: none; }

.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

.phone-link, .email-link {
  color: var(--accent);
  text-decoration: none;
}

.tag {
  font-size: 10px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Action Bar ──────────────────────────────────────────────────────────── */
.action-bar {
  position: fixed;
  bottom: var(--tab-height);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.action-btn {
  flex: 1;
  display: block;
  padding: 11px 4px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.action-btn:active { opacity: 0.75; }

.action-call   { background: var(--green);   color: white; }
.action-text   { background: #8e44ad;        color: white; }
.action-email  { background: var(--accent);  color: white; }
.action-contact{ background: var(--primary); color: white; }

/* ── Group actions (AMA) ─────────────────────────────────────────────────── */
.group-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
