/* ==========================================================
   1. COLORS AND SETTINGS
   Colors are stored as variables, so you can change them
   in one place and the whole page updates.
   ========================================================== */
:root {
  box-sizing: border-box;

  /* Keeps content away from phone notches and system bars */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);

  --bg: #d5d7da;      /* page background (grey) */
  --ink: #22262b;     /* main text and logo color */
  --muted: #555b63;   /* softer text color */
  --line: #b4b8bd;    /* thin lines above the features */
  --accent: #f2a900;  /* yellow of the lightning bolt */
  --danger: #b3261e;  /* error and alert text */
  --chart: #f2a900;
  --surface: #f5f6f7;
}

/* If the visitor's device uses dark mode, switch to a darker grey */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #3a3d42;
    --ink: #f1f2f3;
    --muted: #b9bdc3;
    --line: #555a61;
    --danger: #ff8a80;
    --surface: #303338;
  }
}

/* Make every element include padding and border in its width */
*, *::before, *::after {
  box-sizing: inherit;
}

/* ==========================================================
   2. PAGE LAYOUT
   ========================================================== */
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Sora', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 48px 24px;
  text-align: center;
}

main {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ==========================================================
   3. LOGO
   ========================================================== */
.logo {
  width: clamp(150px, 28vw, 210px);
  height: auto;
  cursor: pointer;
}

.logo .bar {
  transform-origin: 50% 100%;
  animation: grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.logo .bar:nth-of-type(2) { animation-delay: 0.1s; }
.logo .bar:nth-of-type(3) { animation-delay: 0.2s; }
.logo .bar:nth-of-type(4) { animation-delay: 0.3s; }

@keyframes grow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .logo .bar { animation: none; }
}

/* ==========================================================
   4. TEXT
   ========================================================== */
h1 {
  margin: 28px 0 10px;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tag {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 300;
  color: var(--muted);
  max-width: 34em;
  line-height: 1.6;
}

/* ==========================================================
   5. FEATURES LIST (home page)
   ========================================================== */
.features {
  list-style: none;
  margin: 44px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 40px;
  width: 100%;
}

.features li {
  flex: 1 1 200px;
  max-width: 230px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
}

.features li strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.features li span {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ==========================================================
   6. FOOTER
   ========================================================== */
footer {
  margin-top: 56px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ==========================================================
   7. LOGIN / REGISTER BUTTONS
   ========================================================== */
.auth-buttons {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: 24px;
  display: flex;
  gap: 10px;
}

.btn {
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-outline { background: transparent; color: var(--ink); }
.btn-solid   { background: var(--ink); color: var(--bg); }
.btn:hover   { opacity: 0.8; }

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================
   8. FORMS (login, register, data entry)
   ========================================================== */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  margin: 24px 0 16px;
  text-align: left;
}

.auth-form label { font-size: 0.9rem; font-weight: 600; }

.auth-form input {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
}

.auth-form input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.auth-form .btn { margin-top: 12px; }

.error { min-height: 1.4em; margin: 0; font-size: 0.9rem; color: var(--danger); }

/* ==========================================================
   9. DASHBOARD
   ========================================================== */
.dashboard { max-width: 900px; align-items: stretch; text-align: left; gap: 24px; }

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dash-header h1 { margin: 0; font-size: 1.8rem; }

.card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.card p  { margin: 4px 0; color: var(--muted); }
.card .value { color: var(--ink); font-weight: 600; }

.entry-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.entry-row .auth-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; margin: 0; }

.alert-box {
  border: 2px solid var(--danger);
  color: var(--danger);
  border-radius: 12px;
  padding: 14px 18px;
  font-weight: 600;
}

.tips { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }

button:disabled { opacity: .55; cursor: wait; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
td .btn { padding: 8px 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 480px) {
  body { padding: 24px 12px; }
  .dashboard { gap: 14px; }
  .card { padding: 14px; }
  .entry-row .auth-form { flex-direction: column; align-items: stretch; }
  .entry-row .auth-form > div, .entry-row input { width: 100%; }
  .dash-header h1 { font-size: 1.5rem; }
}
