/* ═══════════════════════════════════════════════════════════
   OHTTEK — Base / Reset
═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; color-scheme: dark; }
body.light input, body.light select, body.light textarea { color-scheme: light; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Focus-visible (accessibility) ── */
:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}
/* Suppress default :focus ring — use :focus-visible instead */
:focus:not(:focus-visible) { outline: none; }
/* Form fields use box-shadow focus — no outline needed */
.fc:focus-visible { outline: none; }

/* ── Auth screen ── */
#auth-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.auth-card {
  background: var(--s2); border: 1px solid var(--border-l);
  border-radius: 16px; padding: 40px; width: 340px;
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--ac); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
  box-shadow: 0 0 30px var(--ac-glow);
}
.auth-name { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--tx); letter-spacing: -0.5px; }
.auth-sub  { font-size: 12px; color: var(--tx3); margin-top: 3px; }

/* Google OAuth button */
.auth-google-btn {
  width: 100%; justify-content: center; gap: 10px;
  background: var(--s3); color: var(--tx);
  border: 1px solid var(--border-l); border-radius: var(--r);
  padding: 10px 14px; font-size: 13.5px; font-weight: 600;
  margin-bottom: 6px; transition: all .15s;
}
.auth-google-btn:hover { background: var(--s4); border-color: var(--border); box-shadow: 0 2px 12px rgba(66,133,244,.18); }

/* Divider */
.auth-divider {
  position: relative; text-align: center;
  margin: 14px 0; color: var(--tx3); font-size: 11.5px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 40%; height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-divider span { position: relative; padding: 0 8px; background: var(--s2); }

/* Toggle sign-in / create account */
.auth-toggle {
  text-align: center; font-size: 12px; color: var(--tx3);
  margin-top: 14px;
}
.auth-toggle a { color: var(--ac); text-decoration: none; margin-left: 4px; font-weight: 600; }
.auth-toggle a:hover { text-decoration: underline; }

/* T&C ticker */
.auth-terms-ticker {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.auth-terms-ticker-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; background: none; border: none; padding: 0;
  font-size: 11.5px; color: var(--tx3); cursor: pointer;
  text-align: left; line-height: 1.4;
}
.auth-terms-ticker-btn:hover { color: var(--tx2); }
.auth-terms-ticker-btn i { flex-shrink: 0; transition: transform .25s ease; font-size: 11px; }
.auth-terms-ticker-btn.expanded i { transform: rotate(180deg); }
#terms-ticker-body {
  max-height: 0; overflow: hidden;
  transition: max-height .35s ease, opacity .25s ease;
  opacity: 0;
}
#terms-ticker-body.open {
  max-height: 300px; opacity: 1; overflow-y: auto;
}
#terms-ticker-body h4 { font-size: 11px; color: var(--tx2); margin: 10px 0 3px; text-transform: uppercase; letter-spacing: .5px; }
#terms-ticker-body p  { font-size: 11.5px; color: var(--tx3); line-height: 1.55; margin-bottom: 6px; }

/* ── Main layout ── */
#main {
  margin-left: var(--sb-w);
  flex: 1; min-width: 0;
  overflow-x: hidden;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
#content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }
.page { display: none; }
.page.active { display: block; }

/* ── Topbar ── */
#topbar {
  height: var(--tb-h);
  background: var(--s1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
}
.tb-left { display: flex; align-items: center; gap: 12px; }
#tb-actions { display: flex; align-items: center; gap: 8px; }
.hamburger { display: none !important; }


/* ── Grid helpers ── */
.g2  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.g-detail { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.fr  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fr3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .g2, .g3, .g-detail, .fr, .fr3 { grid-template-columns: 1fr; }
  #content { padding: 16px; }
}
@media (max-width: 480px) {
  .auth-card { width: 100%; border-radius: 0; padding: 32px 24px; }
}
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); z-index: 500; width: 260px; box-shadow: 4px 0 24px rgba(0,0,0,.5); }
  #sidebar.open { transform: translateX(0); }
  #sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 499; }
  #sb-overlay.show { display: block; }
  #main { margin-left: 0 !important; }
  .hamburger { display: flex !important; background: none; border: none; color: var(--tx2); font-size: 18px; padding: 4px; }
  #topbar { padding: 0 12px; }
  #content { padding: 12px; }

  /* Filter-bar: wrap cleanly and push the "New X" buttons onto their own row */
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .filter-bar > div[style*="flex:1"] { display: none; }  /* spacer div forces wrap we don't need */

  /* Touch targets: icon-only buttons must be at least 40×40 */
  .btn-icon, .btn-ghost.btn-sm, .btn-sm { min-height: 40px; min-width: 40px; }

  /* Tables: visual hint that they scroll horizontally */
  .tbl-wrap { position: relative; -webkit-overflow-scrolling: touch; }
  .tbl-wrap::after {
    content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 24px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,.25));
    pointer-events: none; border-radius: 0 var(--r-lg) var(--r-lg) 0;
  }
  body.light .tbl-wrap::after { background: linear-gradient(to right, transparent, rgba(0,0,0,.08)); }
}
