/* ── Trade Journal — base styles ─────────────────────────────────────────
   Design tokens per SPEC: light theme, TradeZella-flavoured.            */

:root {
  --bg:          #f7f8fa;
  --card:        #ffffff;
  --border:      #e5e7ee;
  --radius:      12px;
  --accent:      #6c5ce7;
  --accent-soft: #efedfd;
  --win:         #0d9488;
  --loss:        #e5484d;
  --breakeven:   #9aa1b0;
  --text:        #1c2030;
  --text-muted:  #6b7280;
  --sidebar-w:   220px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ─────────────────────────────────────────────────────── */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 18px;
  font-weight: 700;
  font-size: 16px;
}

.sidebar__logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #9b8cf5);
  display: inline-block;
  flex: 0 0 26px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.sidebar__link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}

.sidebar__link:hover {
  background: var(--bg);
  text-decoration: none;
}

.sidebar__link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar__footer {
  margin-top: auto;
  padding: 12px 12px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.sidebar__user { color: var(--text-muted); }
.sidebar__logout { color: var(--text-muted); }
.sidebar__logout:hover { color: var(--loss); text-decoration: none; }

/* Mobile: sidebar becomes a sticky top bar with horizontally scrollable nav */
@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    z-index: 50;
  }
  .sidebar__brand { padding: 0 6px 0 0; flex: 0 0 auto; }
  .sidebar__name { display: none; }               /* logo only, save width */
  .sidebar__nav {
    flex-direction: row;
    margin-top: 0;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1 1 auto;
    min-width: 0;
  }
  .sidebar__nav::-webkit-scrollbar { display: none; }
  .sidebar__link { padding: 7px 10px; white-space: nowrap; font-size: 14px; }
  .sidebar__footer {
    margin-top: 0;
    padding: 0 0 0 8px;
    border-top: 0;
    flex: 0 0 auto;
  }
  .sidebar__user { display: none; }
  .main { padding: 16px 14px; }
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 28px 32px;
}

.page-head { margin-bottom: 20px; }

.page-head__title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

/* ── Cards & tiles ─────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.tile__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}

.tile__value {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

/* P&L colouring */
.pl-win  { color: var(--win); }
.pl-loss { color: var(--loss); }
.pl-be   { color: var(--breakeven); }

/* ── Tables ────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody tr:hover { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-align: center;
}

.btn:hover { background: var(--bg); text-decoration: none; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover { background: #5b4bd5; }

.btn--danger {
  background: var(--loss);
  border-color: var(--loss);
  color: #fff;
}

.btn--block { display: block; width: 100%; }

/* ── Forms ─────────────────────────────────────────────────────────── */

.form__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 5px;
}

.form__label:first-of-type { margin-top: 0; }

.form__input,
.form__select,
.form__textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form .btn { margin-top: 18px; }

.form__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 5px 0 0;
}

/* ── Alerts ────────────────────────────────────────────────────────── */

.alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.alert--error {
  background: #fdf1f1;
  border-color: #f3c6c8;
  color: var(--loss);
}

.alert--success {
  background: #eefaf3;
  border-color: #bfe8d2;
  color: var(--win);
}

/* ── Auth (login / install) ────────────────────────────────────────── */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-card__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

/* ── Empty state ───────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-state__icon {
  font-size: 34px;
  color: var(--breakeven);
  margin-bottom: 8px;
}

.empty-state__title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.empty-state__text {
  margin: 0 auto 18px;
  max-width: 420px;
  color: var(--text-muted);
}
