@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap");

:root {
  --bg-page: #F5EDE4;
  --bg-accent: #d97757;
  --bg-accent-hover: #C15F3C;
  --bg-accent-light: rgba(217,119,87,0.1);
  --card-bg: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #7A7067;
  --text-muted: #A89F97;
  --border: #E8DDD3;
  --radius-card: 16px;
  --radius-btn: 8px;
  --shadow-card: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-fab: 0 6px 20px rgba(217,119,87,0.4);
  --top-bar-height: 56px;
  --max-width-home: 600px;
  --max-width-tracker: 800px;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
* { font-family: "JetBrains Mono","Courier New",monospace; }

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  padding-top: var(--top-bar-height);
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 10% 15%, rgba(217,119,87,0.07) 0%, transparent 45%),
    radial-gradient(circle at 88% 55%, rgba(217,119,87,0.05) 0%, transparent 40%),
    radial-gradient(circle at 50% 92%, rgba(217,119,87,0.06) 0%, transparent 35%);
}
body > * { position: relative; z-index: 1; }
a { color: inherit; }
button,input,textarea,select { font-family: "JetBrains Mono",monospace; }

/* TOP BAR */
.top-bar {
  position: fixed; top: 0; left: 0;
  width: 100%; height: var(--top-bar-height);
  background: var(--bg-accent);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 24px; z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.brand { color: white; font-weight: 700; font-size: 1.05rem; text-decoration: none; letter-spacing: -0.02em; }
.brand:hover { opacity: 0.9; }
.back-link { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 0.82rem; }
.back-link:hover { opacity: 0.7; }

/* LANG SWITCHER */
.lang-switcher { display: flex; gap: 3px; background: rgba(255,255,255,0.15); padding: 3px; border-radius: 10px; }
.lang-tab { cursor: pointer; color: rgba(255,255,255,0.75); font-size: 0.76rem; font-weight: 700; padding: 4px 8px; border-radius: 7px; transition: background 0.2s,color 0.2s; user-select: none; }
.lang-tab:hover { color: white; }
.lang-tab.active { background: rgba(255,255,255,0.25); color: white; }

/* LAYOUT */
.container { margin: 0 auto; padding: 40px 20px 60px; flex: 1; width: 100%; }
.container-home { max-width: var(--max-width-home); }
.container-tracker { max-width: var(--max-width-tracker); }

/* TYPOGRAPHY */
.welcome-text { color: var(--text-secondary); margin-bottom: 28px; line-height: 1.7; font-size: 0.9rem; }
h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }

/* CARDS */
.card { background: var(--card-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card); border: 1px solid var(--border); margin-bottom: 24px; overflow: hidden; }
.card-header { padding: 16px 20px; display: flex; align-items: center; cursor: pointer; user-select: none; font-weight: 700; font-size: 0.9rem; transition: background 0.15s; }
.card-header:hover { background: #FAFAFA; }
.card-header .chevron { margin-right: 10px; display: inline-block; transition: transform 0.3s; color: var(--text-muted); }
.card.collapsed .chevron { transform: rotate(0deg); }
.card.expanded  .chevron { transform: rotate(90deg); }
.card-body { padding: 0 20px 20px; max-height: 2000px; opacity: 1; overflow: hidden; transition: max-height 0.4s ease, opacity 0.3s, padding 0.3s; }
.card.collapsed .card-body { max-height: 0; opacity: 0; padding-bottom: 0; }

/* LIST ITEMS */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: inherit; transition: opacity 0.2s; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { opacity: 0.7; }
.list-item .label { font-weight: 700; font-size: 0.88rem; }
.list-item .value { color: var(--text-secondary); font-size: 0.82rem; display: flex; align-items: center; gap: 6px; }

/* BUTTONS */
.btn { background: var(--bg-accent); color: white; border: none; border-radius: var(--radius-btn); padding: 10px 20px; font-size: 0.84rem; font-weight: 700; cursor: pointer; transition: background 0.2s,transform 0.1s; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--bg-accent-hover); }
.btn:active { transform: scale(0.98); }
.btn-secondary { background: #EEEAE6; color: var(--text-primary); }
.btn-secondary:hover { background: #E0DBD5; }

/* PILLS */
.pill-tabs { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.pill-tabs::-webkit-scrollbar { display: none; }
.pill { background: #EEEAE6; color: var(--text-secondary); padding: 6px 14px; border-radius: 20px; font-size: 0.76rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background 0.2s,color 0.2s; user-select: none; }
.pill:hover { background: #E0DBD5; color: var(--text-primary); }
.pill.active { background: var(--text-primary); color: white; }

/* CHART */
.chart-container { position: relative; width: 100%; min-height: 280px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--text-secondary); }
.section-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.section-breakdown { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.section-breakdown-item { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--text-secondary); }

/* LOG ENTRIES */
.log-date-header { display: flex; align-items: center; cursor: pointer; padding: 12px 0; border-bottom: 1px solid var(--border); user-select: none; font-weight: 700; font-size: 0.84rem; transition: opacity 0.2s; }
.log-date-header:hover { opacity: 0.7; }
.log-date-header .chevron { margin-right: 8px; display: inline-block; transition: transform 0.3s; color: var(--text-muted); }
.log-date-header.expanded .chevron { transform: rotate(90deg); }
.log-entries { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
.log-entries.open { max-height: 3000px; }
.log-entry { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 0 8px 18px; font-size: 0.8rem; border-bottom: 1px solid #F5F5F5; color: var(--text-secondary); line-height: 1.5; }
.log-entry:last-child { border-bottom: none; }
.log-entry-actions { display: flex; gap: 4px; margin-left: 8px; flex-shrink: 0; }
.log-entry-actions button { background: none; border: none; cursor: pointer; font-size: 0.85rem; opacity: 0.4; padding: 2px 4px; transition: opacity 0.2s; font-family: inherit; }
.log-entry-actions button:hover { opacity: 1; }

/* FOOTER */
footer { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 0.75rem; margin-top: auto; }

/* MODALS */
.modal-overlay { position: fixed; inset: 0; background: rgba(26,26,26,0.45); display: flex; justify-content: center; align-items: center; z-index: 2000; opacity: 0; pointer-events: none; transition: opacity 0.25s; backdrop-filter: blur(2px); }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal { background: var(--card-bg); width: 90%; max-width: 420px; border-radius: var(--radius-card); padding: 28px; position: relative; transform: translateY(16px) scale(0.98); transition: transform 0.25s; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal h3 { margin-bottom: 20px; }
.modal-close { position: absolute; top: 16px; right: 16px; cursor: pointer; color: var(--text-muted); font-size: 1rem; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }

/* FORMS */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.form-control { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-btn); font-size: 0.88rem; color: var(--text-primary); background: white; transition: border-color 0.2s,box-shadow 0.2s; outline: none; }
.form-control:focus { border-color: var(--bg-accent); box-shadow: 0 0 0 3px var(--bg-accent-light); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error-msg { color: #CC2200; font-size: 0.76rem; margin-top: 8px; padding: 8px 10px; background: rgba(204,34,0,0.06); border-radius: 6px; }

/* FAB */
.fab { position: fixed; bottom: 28px; right: 28px; width: 54px; height: 54px; border-radius: 50%; background: var(--bg-accent); color: white; display: flex; justify-content: center; align-items: center; box-shadow: var(--shadow-fab); cursor: pointer; z-index: 1000; border: none; font-size: 1.6rem; line-height: 1; transition: background 0.2s,transform 0.15s,box-shadow 0.2s; }
.fab:hover { background: var(--bg-accent-hover); transform: scale(1.06); }
.fab:active { transform: scale(0.97); }

/* ADMIN */
.sign-out-link { color: rgba(255,255,255,0.8); font-size: 0.72rem; cursor: pointer; text-decoration: underline; }
.sign-out-link:hover { opacity: 0.7; }
.login-section { max-width: 360px; margin: 60px auto; }
.login-section h2 { margin-bottom: 24px; text-align: center; }

/* STATES */
.empty-state { text-align: center; padding: 36px 20px; color: var(--text-muted); font-size: 0.84rem; line-height: 1.6; }
.loading-state { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.8rem; }
.loading-spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--bg-accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* DISCLAIMER */
.disclaimer { margin-top: 40px; padding: 20px 22px; background: rgba(217,119,87,0.06); border: 1px solid rgba(217,119,87,0.2); border-radius: var(--radius-card); color: var(--text-secondary); font-size: 0.76rem; line-height: 1.8; }
.disclaimer h3 { font-size: 0.78rem; margin-bottom: 10px; color: var(--bg-accent); text-transform: uppercase; letter-spacing: 0.06em; }

/* UTILS */
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.hidden { display: none !important; }

/* MOBILE */
@media (max-width: 640px) {
  .top-bar { padding: 0 14px; }
  .brand { font-size: 0.9rem; }
  .container { padding: 20px 14px 48px; }
  .modal { width: 92%; max-width: none; border-radius: var(--radius-card); padding: 24px; padding-top: 30px; overflow-y: auto; max-height: 90vh; }
  .chart-container { min-height: 200px; }
  .section-breakdown { grid-template-columns: repeat(2,1fr); }
  .log-entry { flex-direction: column; gap: 4px; }
  .log-entry-actions { align-self: flex-end; }
  .flex-between { flex-direction: column; align-items: flex-start; }
  .form-row { grid-template-columns: 1fr; }
  .fab { bottom: 20px; right: 20px; width: 50px; height: 50px; font-size: 1.4rem; }
}
