/* ===========================================================
   Earnings Calendar — styles.css
   Theme: iOS 26-inspired, light mode, professional business
   =========================================================== */

:root {
  --bg: #f4f6fb;
  --bg-grad-1: #eef3fb;
  --bg-grad-2: #f7f5fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --primary-soft: #eaf1ff;
  --accent: #6366f1;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;

  /* Recorded label = blue, Unrecorded = soft */
  --rec-bg: linear-gradient(135deg, #2563eb 0%, #4f7dff 100%);
  --rec-fg: #ffffff;
  --tba-bg: #ffffff;
  --tba-fg: #0f172a;
  --tba-border: rgba(15, 23, 42, 0.10);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.14);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;

  /* Sector palette — chosen so none collide with the recorded blue */
  --sec-1: #ef4444; /* Game */
  --sec-2: #f59e0b; /* Digital Content */
  --sec-3: #10b981; /* Social */
  --sec-4: #8b5cf6; /* Cloud & AI */
  --sec-5: #14b8a6; /* FinTech */
  --sec-6: #ec4899; /* eCommerce */
  --sec-7: #f97316; /* Advertising */
  --sec-8: #64748b; /* Other */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -200px, #e6efff 0%, transparent 60%),
    radial-gradient(1000px 500px at -200px 100%, #efe6ff 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" on, "lnum" on;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ============== Header ============== */
.page-header {
  position: sticky;
  top: 12px;
  z-index: 20;
  margin: 16px 16px 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 240px; }
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2563eb 0%, #6366f1 60%, #8b5cf6 100%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.4);
}
.brand-text h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.last-update { margin: 2px 0 0; color: var(--text-3); font-size: 12px; }

.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 14px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s, transform .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: linear-gradient(180deg, #ffffff, #f1f5ff);
  color: var(--primary);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 1px 2px rgba(15,23,42,0.06);
}

/* ============== Layout ============== */
.container { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.card-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; flex: 0 0 auto; }

/* ============== Mini calendar (Tab 1 top) ============== */
.mini-cal-card { padding-bottom: 14px; }
.mini-cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
}
.mini-cell {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 10px 8px;
  min-height: 102px;
  display: flex;
  flex-direction: column;
}
.mini-cell.today { background: linear-gradient(180deg,#eaf1ff,#ffffff); border-color: rgba(37,99,235,.35); }
.mini-cell.past  { opacity: .85; }
.mini-cell .mini-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 6px;
}
.mini-cell .dow { font-size: 11px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.mini-cell .dom { font-size: 18px; font-weight: 700; }
.mini-cell.today .dom { color: var(--primary); }
.mini-cell .events { display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.mini-evt {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; line-height: 1.25;
  padding: 4px 6px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.mini-evt:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mini-evt .evt-zh { font-weight: 700; }
.mini-evt .evt-tk { color: var(--text-3); }
.mini-evt .evt-q  { margin-left: auto; color: var(--primary); font-weight: 700; }
.mini-cell .more { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============== Legend ============== */
.legend {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  padding: 10px 18px;
  border-top: 1px dashed var(--line);
}
.card-head .legend { padding: 0; border-top: 0; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.95), 0 0 0 2.5px rgba(15,23,42,0.18);
  display: inline-block;
}

/* ============== Peer grid (Tab 1 bottom) ============== */
.peer-card { padding-bottom: 12px; }
.peer-controls {
  margin-left: auto;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
}
.ctrl { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.ctrl.grow { flex: 1 1 220px; min-width: 200px; }
.ctrl > span { font-size: 11px; color: var(--text-3); letter-spacing: .03em; }
.ctrl select, .ctrl input, .ctrl textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.ctrl select:focus, .ctrl input:focus, .ctrl textarea:focus {
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
  background: #fff;
}

.peer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 14px 18px 18px;
}
.peer-card-item {
  position: relative;
  border-radius: 14px;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
  min-height: 96px;
}
.peer-card-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.peer-card-item .zh   { font-size: 15px; font-weight: 800; letter-spacing: -0.005em; line-height: 1.15; }
.peer-card-item .tk   { font-size: 11px; opacity: .9; margin-top: 2px; }
.peer-card-item .dt   { font-size: 11.5px; margin-top: 8px; opacity: .92; }
.peer-card-item .tba  {
  position: absolute; top: 8px; right: 10px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  color: var(--warning);
  background: rgba(245,158,11,.12);
  border: 1px solid rgba(245,158,11,.35);
  border-radius: 999px;
  padding: 2px 8px;
}
.peer-card-item .sectors {
  position: absolute; left: 10px; bottom: 8px;
  display: flex; gap: 4px;
}
.peer-card-item.recorded {
  background: var(--rec-bg);
  color: var(--rec-fg);
  border-color: rgba(37,99,235,.35);
  box-shadow: 0 6px 18px rgba(37,99,235,.18);
}
.peer-card-item.recorded .tk,
.peer-card-item.recorded .dt { color: rgba(255,255,255,0.92); }
.peer-card-item.tba {
  background: var(--tba-bg);
  color: var(--tba-fg);
  border-color: var(--tba-border);
}
.peer-card-item .sectors .dot {
  /* high-contrast outline so blue rectangle does not swallow blue-ish dots */
  box-shadow: 0 0 0 1.5px #ffffff, 0 0 0 2.5px rgba(15,23,42,0.45);
}

/* ============== All Records table ============== */
.all-controls { margin-left: auto; display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.all-meta {
  padding: 8px 18px; font-size: 12px; color: var(--text-3);
  border-bottom: 1px solid var(--line);
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.all-meta .pill {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; color: var(--text-2);
}
.table-wrap { overflow: auto; padding: 0 8px 16px; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 12px; color: var(--text-3); font-weight: 700;
  background: var(--surface);
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
}
.data-table tbody td {
  padding: 11px 12px; font-size: 13.5px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.sortable { cursor: pointer; user-select: none; }
.sortable::after { content: " ↕"; color: var(--text-3); opacity: .5; }
.sortable.asc::after  { content: " ↑"; opacity: 1; color: var(--primary); }
.sortable.desc::after { content: " ↓"; opacity: 1; color: var(--primary); }

/* ============== Compare ============== */
.compare-controls { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.compare-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; padding: 14px 18px; }
.summary-tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.summary-tile .k { font-size: 11px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.summary-tile .v { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -0.01em; }
.summary-tile.lead-a { border-color: rgba(37,99,235,.35); background: linear-gradient(180deg,#eaf1ff,#ffffff); }
.summary-tile.lead-b { border-color: rgba(99,102,241,.35); background: linear-gradient(180deg,#efeeff,#ffffff); }
.summary-tile.same   { border-color: rgba(22,163,74,.30); background: linear-gradient(180deg,#e9f7ee,#ffffff); }

.cmp-tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-left: 6px;
  border: 1px solid transparent;
}
.cmp-tag.lead-a { background: rgba(37,99,235,.10);  color: var(--primary); border-color: rgba(37,99,235,.25); }
.cmp-tag.lead-b { background: rgba(99,102,241,.10); color: #4f46e5;        border-color: rgba(99,102,241,.30); }
.cmp-tag.same   { background: rgba(22,163,74,.10);  color: var(--success); border-color: rgba(22,163,74,.30); }
.cmp-tag.miss   { background: var(--surface-2);     color: var(--text-3);  border-color: var(--line); }

/* ============== Buttons ============== */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform .12s, box-shadow .12s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.primary {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff; border-color: rgba(37,99,235,.5);
  box-shadow: 0 6px 18px rgba(37,99,235,.25);
}
.btn.primary:hover { box-shadow: 0 10px 22px rgba(37,99,235,.30); }
.btn.danger { background: linear-gradient(180deg,#ef4444,#dc2626); color:#fff; border-color: rgba(220,38,38,.5);}
.btn.ghost { background: transparent; }
.icon-btn { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--text-3); width: 32px; height: 32px; border-radius: 50%; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============== Modal ============== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card { width: min(560px, 100%); padding: 0; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-body .row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-foot { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal-foot .grow { flex: 1; }
.modal-msg { font-size: 12.5px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.modal-msg.error  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.modal-msg.ok     { background: #ecfdf5; border-color: #bbf7d0; color: #065f46; }

/* ============== Toast ============== */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px;
  background: rgba(15, 23, 42, 0.92); color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg); z-index: 60;
}
.toast[hidden] { display: none; }

@media (max-width: 720px) {
  .mini-cal { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 10px; }
  .mini-cell { min-height: 88px; padding: 8px; }
  .mini-evt .evt-zh { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .peer-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .page-header { top: 8px; margin: 8px 8px 0; padding: 10px 12px; }
  .container { padding: 8px; }
}
