/* Bahabin Google-Finance-inspired visual system. Original artwork and layout rules. */
:root{
  --gf-bg:#f8f9fa;
  --gf-card:#fff;
  --gf-border:#e1e4e8;
  --gf-text:#202124;
  --gf-muted:#5f6368;
  --gf-blue:#1a73e8;
  --gf-blue-soft:#e8f0fe;
  --gf-green:#137333;
  --gf-red:#c5221f;
  --gf-shadow:0 1px 2px rgba(60,64,67,.10),0 1px 4px rgba(60,64,67,.06);
  --gf-radius:14px;
  --gf-content:min(1240px,calc(100% - 32px));
  --market-art:rgba(26,115,232,.11);
  --market-art-red:rgba(197,34,31,.065);
}
html[data-theme="dark"]{
  --gf-bg:#111418;
  --gf-card:#1b1e22;
  --gf-border:#34383d;
  --gf-text:#e8eaed;
  --gf-muted:#9aa0a6;
  --gf-blue:#8ab4f8;
  --gf-blue-soft:#1a2b45;
  --gf-green:#81c995;
  --gf-red:#f28b82;
  --gf-shadow:0 1px 3px rgba(0,0,0,.35);
  --market-art:rgba(138,180,248,.11);
  --market-art-red:rgba(242,139,130,.05);
}

/* Global surface */
body{isolation:isolate;background:var(--gf-bg);color:var(--gf-text);font-family:Vazirmatn,Tahoma,Arial,sans-serif;}
body:not(.font-sans){font-family:Vazirmatn,Tahoma,Arial,sans-serif;}
a{color:var(--gf-blue);}

/* Original full-page artwork: inline SVG injected into every page. */
.bahabin-market-art{
  position:fixed;inset:0;z-index:-1;pointer-events:none;overflow:hidden;
  color:var(--market-art);opacity:1;
}
.bahabin-market-art svg{display:block;width:100%;height:100%;}
.bahabin-market-art .art-grid{stroke:currentColor;stroke-width:1;opacity:.72;}
.bahabin-market-art .art-line{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;}
.bahabin-market-art .art-up{stroke:currentColor;}
.bahabin-market-art .art-down{stroke:var(--market-art-red);}
.bahabin-market-art .art-bar{fill:none;stroke:currentColor;stroke-width:10;opacity:.30;}
.bahabin-market-art .art-wick{stroke:currentColor;stroke-width:2;opacity:.45;}
.bahabin-market-art .art-fill{fill:currentColor;opacity:.035;}

/* Google Finance-like header/nav */
header.top, header.time-header, header{background:var(--gf-card)!important;border-color:var(--gf-border)!important;box-shadow:none!important;}
.topin,.head,.time-head,.time-inner,.wrap,.top .wrap{max-width:1240px;}
.brand-logo,.header-brand-logo{height:40px!important;max-width:190px;object-fit:contain;}
nav a,.top nav a{font-weight:600;text-decoration:none;color:var(--gf-text);}
nav a:hover,.top nav a:hover{color:var(--gf-blue);}

/* Homepage utility tabs */
#mainNav{scrollbar-width:none;}
#mainNav::-webkit-scrollbar{display:none;}
#mainNav .nav-tab,#mainNav>a{min-height:48px;display:inline-flex;align-items:center;justify-content:center;}
#mainNav .nav-tab{border-bottom-width:2px!important;}
#mainNav .nav-tab:hover,#mainNav>a:hover{background:transparent!important;color:var(--gf-blue)!important;}

/* Ticker: clean compact Google-Finance-like cards */
#ticker{gap:.2rem!important;align-items:stretch!important;height:50px!important;}
#ticker .ticker-link{height:50px;display:inline-flex;align-items:center;gap:.5rem;padding:0 .8rem;border-left:1px solid var(--gf-border);border-radius:0;background:transparent;transition:background .15s ease;}
#ticker .ticker-link:hover{background:var(--gf-blue-soft);}
#ticker .ticker-name{font-weight:700;}
#ticker .ticker-price{font-weight:650;}
#ticker .ticker-change{font-size:.76rem;font-weight:700;}

/* Common cards/tables */
.card,.panel,.box,.section-card,section.card,article.card{background:var(--gf-card);border:1px solid var(--gf-border)!important;border-radius:var(--gf-radius)!important;box-shadow:var(--gf-shadow)!important;}
.table-wrap{border-radius:12px;overflow:auto;}
table{border-color:var(--gf-border)!important;}
table th{font-weight:650;}
table td,table th{border-color:var(--gf-border)!important;}
tbody tr:hover td{background:var(--gf-blue-soft)!important;}

/* Buttons/inputs */
button,input,select,textarea{font-family:inherit;}
button,.btn{border-radius:10px;}
input,select,textarea{background:var(--gf-card);color:var(--gf-text);border-color:var(--gf-border)!important;}
input:focus,select:focus,textarea:focus{outline:2px solid rgba(26,115,232,.16);border-color:var(--gf-blue)!important;}

/* Home dashboard proportions */
#catChips .th-chip{border-radius:999px!important;}
section.th-surface,aside>div.th-surface{border-radius:var(--gf-radius)!important;box-shadow:var(--gf-shadow)!important;}
#mainTable tbody td{vertical-align:middle;}

/* Detail / category pages */
main.wrap,.wrap{max-width:1240px;}
main{position:relative;z-index:1;}
main h1{letter-spacing:-.015em;}
.lead,.muted,.subtitle{color:var(--gf-muted)!important;}

/* Make category pages feel like a finance terminal */
.market-grid,.grid,.stats,.results{gap:14px;}
.price-card,.market-card,.quote-card,.stat-card{background:var(--gf-card);border:1px solid var(--gf-border);border-radius:14px;box-shadow:var(--gf-shadow);}

/* Analysis */
.analysis-card,.chart-card,.metric-card{background:var(--gf-card)!important;border:1px solid var(--gf-border)!important;border-radius:14px!important;box-shadow:var(--gf-shadow)!important;}
canvas{max-width:100%;}

/* Footer */
footer{border-color:var(--gf-border)!important;background:transparent!important;color:var(--gf-muted);}

@media(max-width:800px){
  :root{--gf-content:min(100% - 20px,1240px);}
  .bahabin-market-art{opacity:.62;}
  .brand-logo,.header-brand-logo{height:34px!important;max-width:150px;}
  #ticker .ticker-link{padding:0 .6rem;}
}
@media(prefers-reduced-motion:reduce){
  .bahabin-market-art{opacity:.48;}
  #ticker{animation:none!important;transform:none!important;}
}

/* Persistent theme across every static page. The homepage stores the preference in localStorage;
   this shared layer restores it before the page paints and gives other page layouts dark tokens too. */
html[data-theme="dark"] body{
  --bg:#111418;
  --surface:#1b1e22;
  --surface2:#20252a;
  --text:#e8eaed;
  --muted:#9aa0a6;
  --border:#34383d;
  --accent:#8ab4f8;
  --good:#81c995;
  --bad:#f28b82;
  background:var(--gf-bg)!important;
  color:var(--gf-text)!important;
}
html[data-theme="dark"] body,
html[data-theme="dark"] main,
html[data-theme="dark"] section,
html[data-theme="dark"] article,
html[data-theme="dark"] aside,
html[data-theme="dark"] footer,
html[data-theme="dark"] header{
  color-scheme:dark;
}
html[data-theme="dark"] .header,
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .quote-card,
html[data-theme="dark"] .card,
html[data-theme="dark"] .tool,
html[data-theme="dark"] .note,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .source-box,
html[data-theme="dark"] .price-card,
html[data-theme="dark"] .market-card,
html[data-theme="dark"] .quote-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .box,
html[data-theme="dark"] .section-card{
  background:var(--gf-card)!important;
  color:var(--gf-text)!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] .stat,
html[data-theme="dark"] .surface-2,
html[data-theme="dark"] .soft,
html[data-theme="dark"] .bg-gray-50,
html[data-theme="dark"] .bg-slate-50{
  background:var(--surface2)!important;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .range button{
  background:var(--gf-card)!important;
  color:var(--gf-text)!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] .nav a,
html[data-theme="dark"] .footer-col a,
html[data-theme="dark"] .label,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .lead,
html[data-theme="dark"] .subtitle{
  color:var(--gf-muted)!important;
}
html[data-theme="dark"] table th,
html[data-theme="dark"] table td,
html[data-theme="dark"] .history-table th,
html[data-theme="dark"] .history-table td{
  color:var(--gf-text);
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] tbody tr:hover td{
  background:var(--gf-blue-soft)!important;
}
html[data-theme="dark"] .brand span,
html[data-theme="dark"] a:hover,
html[data-theme="dark"] .nav a:hover{
  color:var(--gf-blue)!important;
}
html[data-theme="dark"] .bahabin-market-art{opacity:.58;}



/* ===== Bahabin global dark-theme completion ===== */
html[data-theme="dark"] {
  --gf-bg:#0f1318;
  --gf-card:#171b21;
  --gf-border:#303741;
  --gf-text:#edf2f7;
  --gf-muted:#a7b0bb;
  --gf-blue:#8ab4f8;
  --gf-blue-soft:#18283e;
  --gf-green:#7ee2a8;
  --gf-red:#ff8b84;
}
html[data-theme="dark"] body,
html[data-theme="dark"] body.calendar-page {
  background:var(--gf-bg)!important;
  color:var(--gf-text)!important;
}
html[data-theme="dark"] body::selection { background:#2a4a74; color:#fff; }

/* All common light surfaces */
html[data-theme="dark"] .top,
html[data-theme="dark"] .header,
html[data-theme="dark"] .time-header,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .box,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .quote-card,
html[data-theme="dark"] .price-card,
html[data-theme="dark"] .market-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .method,
html[data-theme="dark"] .tool,
html[data-theme="dark"] .note,
html[data-theme="dark"] .source-box,
html[data-theme="dark"] .updated,
html[data-theme="dark"] .live,
html[data-theme="dark"] .calendar-panel,
html[data-theme="dark"] .events-panel,
html[data-theme="dark"] .calendar-grid-wrap,
html[data-theme="dark"] .calendar-today,
html[data-theme="dark"] .today-panel {
  background:var(--gf-card)!important;
  color:var(--gf-text)!important;
  border-color:var(--gf-border)!important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button:not(.btn.primary):not(.th-brand-bg),
html[data-theme="dark"] .range button,
html[data-theme="dark"] .calendar-today button {
  background:#1b2027!important;
  color:var(--gf-text)!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] .btn.primary,
html[data-theme="dark"] .th-brand-bg {
  background:var(--gf-blue)!important;
  color:#0b1220!important;
  border-color:var(--gf-blue)!important;
}
html[data-theme="dark"] .btn,
html[data-theme="dark"] .brand,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .value,
html[data-theme="dark"] .live-name,
html[data-theme="dark"] .coin-name,
html[data-theme="dark"] .month-current,
html[data-theme="dark"] .today-info h1,
html[data-theme="dark"] .today-clock {
  color:var(--gf-text)!important;
}
html[data-theme="dark"] .muted,
html[data-theme="dark"] .lead,
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .label,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .small,
html[data-theme="dark"] .crumb,
html[data-theme="dark"] .status,
html[data-theme="dark"] .method,
html[data-theme="dark"] .footer-brand p,
html[data-theme="dark"] .copyright {
  color:var(--gf-muted)!important;
}
html[data-theme="dark"] a { color:var(--gf-blue); }
html[data-theme="dark"] a:hover { color:#aecbfa!important; }

/* Tables / data rows */
html[data-theme="dark"] table th,
html[data-theme="dark"] table thead th,
html[data-theme="dark"] .coin-table th,
html[data-theme="dark"] .history-table th {
  background:#1c2229!important;
  color:var(--gf-muted)!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] table td,
html[data-theme="dark"] table th,
html[data-theme="dark"] .coin-table td,
html[data-theme="dark"] .coin-table th,
html[data-theme="dark"] .history-table td,
html[data-theme="dark"] .history-table th {
  border-color:var(--gf-border)!important;
  color:var(--gf-text);
}
html[data-theme="dark"] tbody tr:hover td { background:#1d2a3b!important; }
html[data-theme="dark"] .surface-2,
html[data-theme="dark"] .soft,
html[data-theme="dark"] .bg-gray-50,
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-white { background:var(--gf-card)!important; }

/* Calendar: override the page's legacy hard-coded whites */
html[data-theme="dark"] body.calendar-page,
html[data-theme="dark"] body.calendar-page .time-main,
html[data-theme="dark"] body.calendar-page .calendar-panel {
  background:var(--gf-bg)!important;
  color:var(--gf-text)!important;
}
html[data-theme="dark"] body.calendar-page .time-header,
html[data-theme="dark"] body.calendar-page .time-header-inner,
html[data-theme="dark"] body.calendar-page .calendar-panel,
html[data-theme="dark"] body.calendar-page .calendar-toolbar,
html[data-theme="dark"] body.calendar-page .today-panel,
html[data-theme="dark"] body.calendar-page .events-panel,
html[data-theme="dark"] body.calendar-page .calendar-today,
html[data-theme="dark"] body.calendar-page .year-form {
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] body.calendar-page .time-header {
  background:#151a20!important;
}
html[data-theme="dark"] body.calendar-page .time-brand,
html[data-theme="dark"] body.calendar-page .today-line,
html[data-theme="dark"] body.calendar-page .daynum {
  color:var(--gf-text)!important;
}
html[data-theme="dark"] body.calendar-page .today-line.muted,
html[data-theme="dark"] body.calendar-page .month-before,
html[data-theme="dark"] body.calendar-page .month-after,
html[data-theme="dark"] body.calendar-page .year-box span,
html[data-theme="dark"] body.calendar-page .event-list small,
html[data-theme="dark"] body.calendar-page .calendar-footer,
html[data-theme="dark"] body.calendar-page .gdate {
  color:var(--gf-muted)!important;
}
html[data-theme="dark"] body.calendar-page .time-header nav a { color:var(--gf-muted)!important; }
html[data-theme="dark"] body.calendar-page .time-header nav a.active { color:var(--gf-blue)!important;background:#172a40!important; }
html[data-theme="dark"] body.calendar-page .calendar-grid-wrap,
html[data-theme="dark"] body.calendar-page .cal-grid {
  background:#171b21!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] body.calendar-page .cal-dow {
  background:#1b2027!important;
  color:var(--gf-muted)!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] body.calendar-page .cal-cell {
  background:#171b21!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] body.calendar-page .cal-cell.empty { background:#14181d!important; }
html[data-theme="dark"] body.calendar-page .cal-cell.weekend { background:#1c2026!important; }
html[data-theme="dark"] body.calendar-page .cal-cell.holiday { background:#241b1d!important; }
html[data-theme="dark"] body.calendar-page .cal-cell.today { box-shadow:inset 0 0 0 2px var(--gf-blue)!important; }
html[data-theme="dark"] body.calendar-page .event { color:#b3bdc8!important; }
html[data-theme="dark"] body.calendar-page .event.h,
html[data-theme="dark"] body.calendar-page .weekend .daynum,
html[data-theme="dark"] body.calendar-page .holiday .daynum,
html[data-theme="dark"] body.calendar-page .event-list li.holiday { color:#ff8b84!important; }
html[data-theme="dark"] body.calendar-page .month-arrow { color:var(--gf-muted)!important;background:#171b21!important; }
html[data-theme="dark"] body.calendar-page .year-box,
html[data-theme="dark"] body.calendar-page .year-form input { background:#171b21!important;color:var(--gf-text)!important;border-color:var(--gf-border)!important; }
html[data-theme="dark"] body.calendar-page .calendar-today button { color:var(--gf-blue)!important; }
html[data-theme="dark"] body.calendar-page .event-list li { border-color:var(--gf-border)!important;color:var(--gf-text)!important; }

/* Analysis: override its legacy fixed light palette */
html[data-theme="dark"] body:has(.chart-grid),
html[data-theme="dark"] body:has(.chart-grid) .top,
html[data-theme="dark"] body:has(.chart-grid) .controls,
html[data-theme="dark"] body:has(.chart-grid) .stat,
html[data-theme="dark"] body:has(.chart-grid) .chart-card,
html[data-theme="dark"] body:has(.chart-grid) .table-card,
html[data-theme="dark"] body:has(.chart-grid) .method {
  background:var(--gf-card)!important;
  color:var(--gf-text)!important;
  border-color:var(--gf-border)!important;
}
html[data-theme="dark"] body:has(.chart-grid) .lead { color:var(--gf-muted)!important; }
html[data-theme="dark"] body:has(.chart-grid) .field select,
html[data-theme="dark"] body:has(.chart-grid) .btn:not(.primary) { background:#1b2027!important;color:var(--gf-text)!important; }
html[data-theme="dark"] body:has(.chart-grid) th { background:#1c2229!important;color:var(--gf-muted)!important; }
html[data-theme="dark"] body:has(.chart-grid) .error { background:#321b20!important;color:#ffb4ae!important;border-color:#6f3037!important; }
html[data-theme="dark"] body:has(.chart-grid) .dot[style*="#475467"] { filter:brightness(1.4); }

/* Dark-safe logo: the supplied blue wordmark becomes clean white on dark surfaces. */
html[data-theme="dark"] .brand-logo,
html[data-theme="dark"] .header-brand-logo,
html[data-theme="dark"] .time-brand img {
  filter:grayscale(1) brightness(0) invert(1)!important;
}
html[data-theme="light"] .brand-logo,
html[data-theme="light"] .header-brand-logo,
html[data-theme="light"] .time-brand img { filter:none!important; }

/* Footer links: never clip or get truncated by the grid/floating layout. */
.site-footer .footer-grid,
footer .footer-grid,
.footer-grid { grid-template-columns:minmax(220px,1.25fr) repeat(3,minmax(150px,1fr)); align-items:start; }
.footer-brand,.footer-col,.footer-links { min-width:0; }
.footer-col a,
.footer-links a,
footer a { overflow-wrap:anywhere; word-break:normal; white-space:normal; text-overflow:clip; max-width:100%; }
footer .footer-links { display:flex!important; flex-wrap:wrap; justify-content:flex-start; gap:8px 14px; float:none!important; }
footer .footer-links a { display:inline-block; margin:0!important; }
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] footer { background:transparent!important;color:var(--gf-muted)!important;border-color:var(--gf-border)!important; }
html[data-theme="dark"] .footer-title { color:var(--gf-text)!important; }

/* Prevent fixed/legacy page chrome from reintroducing white surfaces in dark mode. */
html[data-theme="dark"] .white,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .panel-white { background:var(--gf-card)!important;color:var(--gf-text)!important; }

@media(max-width:800px){
  .site-footer .footer-grid,
  footer .footer-grid,
  .footer-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:520px){
  .site-footer .footer-grid,
  footer .footer-grid,
  .footer-grid { grid-template-columns:1fr; }
  footer .footer-links { flex-direction:column; align-items:flex-start; }
}
