/* ══════════════════════════════════════════════════════════════
   TERAGEST DEV — App Shell, Topbar, Sidebar, Navigation
   ══════════════════════════════════════════════════════════════ */

/* LOGIN */
#page-login {
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0; z-index: 100; background: var(--bg); padding: 20px;
}
#page-login.hidden { display: none; }
.login-box {
  width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 22px; box-shadow: var(--sh);
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo img {
  width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 14px;
  background: var(--surface2); border: 1px solid var(--border); display: block;
  padding: 6px; box-shadow: var(--sh); object-fit: contain;
}
.login-logo h1 { font-family: var(--mono); font-size: 13px; margin-top: 10px; color: var(--text); font-weight: 600; }
.login-logo p { font-family: var(--mono); font-size: 9px; color: var(--text3); margin-top: 3px; }
.login-err {
  display: none; padding: 7px 10px; background: rgba(220,38,38,.07); border: 1px solid rgba(220,38,38,.28);
  border-radius: 7px; font-family: var(--mono); font-size: 10px; color: var(--danger); margin-bottom: 10px;
}

/* APP SHELL */
#app { display: none; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* TOPBAR */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; padding-top: calc(8px + var(--safe-t));
  min-height: 48px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border); z-index: 10; position: relative;
}
.topbar::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent); opacity: .35;
}
.topbar-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar-logo { width: 26px; height: 26px; border-radius: 7px; object-fit: contain; flex-shrink: 0; }
.topbar-title { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.tbtn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: none;
  cursor: pointer; font-size: 13px; color: var(--text3); display: flex; align-items: center;
  justify-content: center; transition: all .15s; flex-shrink: 0;
}
.tbtn:active { border-color: var(--accent); color: var(--accent); }
.tbtn.active { border-color: var(--accent); color: var(--accent); background: rgba(37,99,235,.08); }
.theme-toggle {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: none;
  cursor: pointer; font-size: 14px; color: var(--text3); display: flex; align-items: center;
  justify-content: center; transition: all .15s; flex-shrink: 0;
}
.theme-toggle:active { border-color: var(--accent); color: var(--accent); }

/* NAV TABS — for switching between views */
#nav-tabs {
  display: flex; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.nav-tab {
  padding: 8px 16px; font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text3); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; white-space: nowrap; transition: all .15s;
  display: flex; align-items: center; gap: 6px;
}
.nav-tab:hover { color: var(--text2); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-tab .tab-badge {
  background: var(--accent); color: #fff; font-size: 8px; padding: 1px 5px;
  border-radius: 8px; min-width: 16px; text-align: center;
}

/* VIEW CONTAINERS */
.view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.view.active { display: flex; }

/* FILTER BAR */
#filter-bar {
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
}
.filter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-row label {
  font-family: var(--mono); font-size: 8px; color: var(--text3);
  letter-spacing: .4px; text-transform: uppercase; flex-shrink: 0; min-width: 40px;
}
.filter-row input, .filter-row select {
  padding: 5px 8px; border-radius: 5px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 11px; font-family: var(--sans);
  outline: none; flex: 1; min-width: 0;
}
.filter-row input:focus, .filter-row select:focus { border-color: var(--accent); }
.filter-row input[type="date"] { max-width: 130px; }
.fbtn-s {
  padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  font-family: var(--mono); font-size: 9px; color: var(--text3); cursor: pointer;
  white-space: nowrap; flex-shrink: 0; transition: all .12s;
}
.fbtn-s.on { background: rgba(37,99,235,.1); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* STATUS BAR */
#status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 12px; padding-bottom: calc(4px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0;
  font-family: var(--mono); font-size: 9px; color: var(--text3);
}
