@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0f1a0f;
  --bg-secondary: #1a2a1a;
  --bg-card: #1e2e1e;
  --bg-card-hover: #243424;
  --bg-input: #152015;
  --forest: #2D4A2D;
  --forest-mid: #3D6B3D;
  --moss: #5C8A4E;
  --sage: #8BAF7A;
  --khaki: #B5A882;
  --dirt: #8B6F47;
  --alert: #C0392B;
  --alert-bg: #2a1111;
  --amber: #D68910;
  --amber-bg: #2a2211;
  --sky: #2980B9;
  --sky-bg: #112233;
  --swiss-red: #FF0000;
  --text-primary: #d4d0a8;
  --text-secondary: #9a9570;
  --text-tertiary: #6b6745;
  --text-heading: #e8e0c8;
  --border: #2a3a2a;
  --border-light: #3a4a3a;
  --font-mono: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
}

html { font-size: 16px; }
body {
  font-family: var(--font-mono);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Container wrapper for centered layout */
.app-wrapper {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-primary);
  min-height: 100vh;
  box-shadow: 0 0 60px rgba(0,0,0,.5);
  position: relative;
}

/* ===== LOGIN ===== */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 90%; max-width: 360px;
  text-align: center;
}
.login-box h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem; font-weight: 800;
  color: var(--text-heading);
  margin-bottom: .3rem;
}
.login-box .subtitle {
  font-size: .75rem; color: var(--sage);
  letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.login-box input {
  width: 100%; padding: .7rem 1rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: var(--font-mono);
  font-size: .9rem; margin-bottom: 1rem;
  outline: none; transition: border-color .15s;
}
.login-box input:focus { border-color: var(--moss); }
.login-box button {
  width: 100%; padding: .7rem;
  background: var(--forest-mid); border: none;
  border-radius: var(--radius-sm);
  color: var(--text-heading); font-family: var(--font-mono);
  font-size: .85rem; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.login-box button:hover { background: var(--moss); }
.login-error {
  color: var(--alert); font-size: .8rem;
  margin-bottom: .8rem; display: none;
}

/* ===== HEADER ===== */
.header {
  background: var(--forest);
  padding: 1.2rem 1.5rem 1rem;
  position: relative; overflow: hidden;
}
.header::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0px, rgba(255,255,255,.015) 1px, transparent 1px, transparent 12px);
}
.header-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  position: relative;
}
.header-title {
  font-family: var(--font-heading);
  font-size: 1.5rem; font-weight: 800;
  color: var(--text-heading); letter-spacing: -.5px;
}
.header-sub {
  font-size: .8rem; color: var(--sage);
  margin-top: 3px; letter-spacing: 1px;
  text-transform: uppercase;
}
.header-actions {
  display: flex; gap: 8px; position: relative;
}
.header-btn {
  background: rgba(255,255,255,.1); border: none;
  border-radius: var(--radius-sm); padding: 6px 10px;
  color: var(--sage); font-size: .75rem;
  cursor: pointer; font-family: var(--font-mono);
  transition: all .15s;
}
.header-btn:hover { background: rgba(255,255,255,.2); color: var(--text-heading); }

.score-bar { margin-top: 14px; position: relative; }
.score-track {
  height: 8px; background: rgba(255,255,255,.12);
  border-radius: 4px; overflow: hidden;
}
.score-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--moss), var(--sage));
  transition: width .6s ease;
}
.score-label {
  font-size: .8rem; color: var(--sage);
  margin-top: 5px; display: flex;
  justify-content: space-between;
}

/* ===== ALERT BANNER ===== */
.alert-banner {
  background: var(--alert-bg); border-bottom: 1px solid #4a1a1a;
  padding: 8px 1.5rem; display: flex;
  align-items: center; gap: 8px;
  font-size: .75rem; color: var(--alert);
  cursor: pointer; transition: background .15s;
}
.alert-banner:hover { background: #331515; }
.alert-banner .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--alert); animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ===== TABS ===== */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 16px; font-size: .8rem;
  font-family: var(--font-mono); cursor: pointer;
  white-space: nowrap; color: var(--text-secondary);
  border: none; border-bottom: 2px solid transparent;
  background: none; transition: all .15s;
  letter-spacing: .3px;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--sage); border-bottom-color: var(--moss);
  font-weight: 500;
}
.tab .badge {
  display: inline-block; min-width: 16px; height: 16px;
  background: var(--alert); color: #fff;
  border-radius: 8px; font-size: .6rem;
  line-height: 16px; text-align: center;
  margin-left: 4px; padding: 0 4px;
}

/* ===== CONTENT ===== */
.content { padding: 1.2rem 1.5rem 6rem; }
.panel { display: none; }
.panel.active { display: block; }

/* ===== CATEGORY HEADERS ===== */
.category-block { margin-bottom: 1.2rem; }
.category-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.cat-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  background: rgba(255,255,255,.05);
}
.cat-title {
  font-family: var(--font-heading);
  font-size: 1.05rem; font-weight: 700;
  color: var(--text-heading);
}
.cat-count {
  font-size: .8rem; color: var(--text-secondary);
  margin-left: auto;
}
.cat-chevron {
  color: var(--text-tertiary); font-size: .8rem;
  transition: transform .2s;
}
.category-block.collapsed .cat-chevron { transform: rotate(-90deg); }
.category-block.collapsed .item-grid,
.category-block.collapsed .cat-actions { display: none; }
.cat-actions {
  display: flex; gap: 6px; margin-bottom: 8px;
}

/* ===== ITEM GRID ===== */
.item-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin-bottom: 8px;
}
@media (max-width: 600px) { .item-grid { grid-template-columns: 1fr; } }

.item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card);
  cursor: pointer; transition: all .15s; user-select: none;
  position: relative;
}
.item:hover { border-color: var(--border-light); background: var(--bg-card-hover); }
.item.checked { background: var(--bg-secondary); opacity: .7; }
.item.checked .item-name {
  color: var(--text-tertiary);
  text-decoration: line-through;
  text-decoration-color: var(--sage);
}

.checkbox {
  width: 18px; height: 18px; border: 1.5px solid var(--border-light);
  border-radius: 4px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
  margin-top: 1px; transition: all .15s;
}
.item.checked .checkbox {
  background: var(--moss); border-color: var(--moss);
}
.checkbox-tick { width: 9px; height: 7px; opacity: 0; transition: opacity .1s; }
.item.checked .checkbox-tick { opacity: 1; }

.item-info { flex: 1; min-width: 0; }
.item-name {
  font-size: .9rem; font-weight: 500;
  color: var(--text-primary); line-height: 1.4;
}
.item-detail {
  font-size: .8rem; color: var(--text-tertiary);
  margin-top: 3px; line-height: 1.4;
}
.item-weight {
  font-size: .75rem; color: var(--dirt);
  margin-top: 3px;
}
.item-actions {
  position: absolute; top: 6px; right: 6px;
  display: none; gap: 4px;
}
.item:hover .item-actions { display: flex; }
.item-btn {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 4px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .65rem; color: var(--text-secondary);
  transition: all .1s;
}
.item-btn:hover { color: var(--text-primary); border-color: var(--border-light); }
.item-btn.delete:hover { color: var(--alert); border-color: var(--alert); }

.priority-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0; margin-top: 6px;
}
.p-critical { background: var(--alert); }
.p-high { background: var(--amber); }
.p-medium { background: var(--sky); }
.p-low { background: var(--sage); }

/* ===== EXPIRY BADGES ===== */
.item-expiry {
  font-size: .72rem; margin-top: 4px;
  padding: 2px 8px; border-radius: 4px;
  display: inline-block; color: var(--sage);
  background: rgba(92,138,78,.12);
}
.item-expiry.expiring-soon {
  color: var(--amber);
  background: rgba(214,137,16,.12);
}
.item-expiry.expired {
  color: var(--alert);
  background: rgba(192,57,43,.15);
  font-weight: 500;
}

/* ===== LEGEND ===== */
.legend {
  display: flex; gap: 12px; padding: 8px 12px;
  background: var(--bg-secondary); border-radius: var(--radius);
  margin-bottom: 12px; flex-wrap: wrap;
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: .7rem; color: var(--text-secondary);
}

/* ===== TIP BOX ===== */
.tip-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--moss);
  border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 10px;
}
.tip-box.warning { border-left-color: var(--amber); }
.tip-box.critical { border-left-color: var(--alert); }
.tip-label {
  font-size: .75rem; text-transform: uppercase;
  letter-spacing: 1px; color: var(--moss);
  font-weight: 500; margin-bottom: 5px;
}
.tip-box.warning .tip-label { color: var(--amber); }
.tip-box.critical .tip-label { color: var(--alert); }
.tip-text {
  font-size: .88rem; color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== WEIGHT BARS ===== */
.weight-section { margin-bottom: 16px; }
.weight-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.weight-label { font-size: .78rem; color: var(--text-secondary); min-width: 110px; }
.weight-track {
  flex: 1; height: 8px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
.weight-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.weight-val { font-size: .78rem; color: var(--text-primary); min-width: 50px; text-align: right; }
.weight-total {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.weight-total .weight-label,
.weight-total .weight-val {
  font-weight: 500; color: var(--text-heading);
}

/* ===== DASHBOARD STATS ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  text-align: center;
}
.stat-value {
  font-family: var(--font-heading);
  font-size: 1.6rem; font-weight: 800;
  color: var(--text-heading);
}
.stat-label {
  font-size: .7rem; color: var(--text-secondary);
  margin-top: 4px;
}
.cat-progress-list { margin-bottom: 16px; }
.cat-progress-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.cat-progress-row:last-child { border-bottom: none; }
.cat-progress-icon { font-size: 1rem; width: 24px; text-align: center; }
.cat-progress-name { font-size: .8rem; color: var(--text-primary); flex: 1; }
.cat-progress-bar {
  width: 80px; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.cat-progress-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.cat-progress-text { font-size: .7rem; color: var(--text-secondary); min-width: 40px; text-align: right; }

/* ===== FORMS & MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  width: 90%; max-width: 440px; max-height: 85vh;
  overflow-y: auto;
}
.modal h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem; font-weight: 700;
  color: var(--text-heading); margin-bottom: 1rem;
}
.form-group { margin-bottom: .8rem; }
.form-label {
  display: block; font-size: .7rem;
  color: var(--text-secondary); margin-bottom: 4px;
  letter-spacing: .5px; text-transform: uppercase;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: .55rem .8rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: var(--font-mono);
  font-size: .85rem; outline: none;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--moss); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-card); }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }

.btn {
  padding: .55rem 1rem; border: none;
  border-radius: var(--radius-sm); font-family: var(--font-mono);
  font-size: .8rem; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--forest-mid); color: var(--text-heading); }
.btn-primary:hover { background: var(--moss); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text-primary); border-color: var(--border-light); }
.btn-danger { background: none; color: var(--alert); border: 1px solid var(--alert); }
.btn-danger:hover { background: var(--alert); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .7rem; }
.btn-block { width: 100%; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1rem; }

/* ===== TODO LIST ===== */
.todo-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card);
  margin-bottom: 6px; transition: all .15s;
  position: relative;
}
.todo-item:hover { border-color: var(--border-light); }
.todo-item.completed { opacity: .5; }
.todo-item.completed .todo-title {
  text-decoration: line-through;
  text-decoration-color: var(--sage);
}
.todo-check {
  width: 20px; height: 20px; border: 1.5px solid var(--border-light);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; cursor: pointer;
  margin-top: 1px; transition: all .15s;
}
.todo-item.completed .todo-check {
  background: var(--moss); border-color: var(--moss);
}
.todo-content { flex: 1; }
.todo-title { font-size: .85rem; color: var(--text-primary); }
.todo-meta {
  display: flex; gap: 8px; margin-top: 4px;
  font-size: .7rem; color: var(--text-tertiary);
}
.todo-due { color: var(--amber); }
.todo-due.overdue { color: var(--alert); }
.todo-actions {
  display: flex; gap: 4px;
  position: absolute; top: 8px; right: 8px;
}

/* ===== REMINDERS ===== */
.reminder-item {
  padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card);
  margin-bottom: 6px; position: relative;
}
.reminder-item.active-reminder {
  border-color: var(--amber);
  background: var(--amber-bg);
}
.reminder-title { font-size: .85rem; color: var(--text-primary); }
.reminder-meta {
  display: flex; gap: 10px; margin-top: 4px;
  font-size: .7rem; color: var(--text-tertiary);
}
.reminder-time { color: var(--sky); }
.reminder-item.active-reminder .reminder-time { color: var(--amber); }
.reminder-repeat { color: var(--sage); }
.reminder-actions {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 4px;
}

/* ===== EVAC SECTION ===== */
.evac-section {
  margin-bottom: 12px;
}
.evac-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all .15s; user-select: none;
}
.evac-header:hover { border-color: var(--border-light); }
.evac-header .icon { font-size: 1.2rem; }
.evac-header .title {
  font-family: var(--font-heading);
  font-size: 1rem; font-weight: 700;
  color: var(--text-heading); flex: 1;
}
.evac-header .chevron {
  color: var(--text-tertiary); transition: transform .2s;
}
.evac-section.open .evac-header .chevron { transform: rotate(180deg); }
.evac-body {
  display: none; padding: 12px;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg-secondary);
}
.evac-section.open .evac-body { display: block; }

/* Evac content styles */
.evac-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.evac-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px;
  text-align: center;
}
.evac-card.evac-critical { border-color: var(--alert); background: var(--alert-bg); }
.evac-card.evac-high { border-color: var(--amber); background: var(--amber-bg); }
.evac-num {
  display: block; font-family: var(--font-heading);
  font-size: 1.2rem; font-weight: 800;
  color: var(--text-heading);
}
.evac-label {
  display: block; font-size: .7rem;
  color: var(--text-secondary); margin-top: 2px;
}
.evac-table {
  width: 100%; border-collapse: collapse;
  font-size: .78rem; margin-bottom: 10px;
}
.evac-table th {
  text-align: left; padding: 6px 8px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  color: var(--sage); font-size: .7rem;
  text-transform: uppercase; letter-spacing: .5px;
}
.evac-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.evac-table tr:last-child td { border-bottom: none; }
.evac-warning {
  background: var(--alert-bg); border: 1px solid #4a2222;
  border-radius: var(--radius-sm); padding: 8px 12px;
  color: var(--alert); font-size: .78rem;
  margin: 8px 0;
}
.evac-tip {
  background: var(--amber-bg); border: 1px solid #4a3a11;
  border-radius: var(--radius-sm); padding: 8px 12px;
  color: var(--amber); font-size: .78rem;
  margin: 8px 0;
}
.evac-body ul { padding-left: 1.2rem; margin: 6px 0; }
.evac-body li {
  font-size: .88rem; color: var(--text-secondary);
  margin-bottom: 5px; line-height: 1.6;
}
.evac-body h4 {
  font-family: var(--font-heading);
  font-size: .85rem; font-weight: 700;
  color: var(--text-heading); margin: 12px 0 6px;
}
.evac-body p {
  font-size: .8rem; color: var(--text-secondary);
  line-height: 1.5; margin: 4px 0;
}
.evac-links {
  display: flex; flex-direction: column; gap: 6px;
}
.evac-links a {
  display: block; padding: 8px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--sky); font-size: .78rem;
  text-decoration: none; transition: all .15s;
}
.evac-links a:hover { border-color: var(--sky); background: var(--sky-bg); }

.sirene-type {
  padding: 12px; border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.sirene-general {
  background: var(--amber-bg); border: 1px solid #4a3a11;
}
.sirene-eau {
  background: var(--sky-bg); border: 1px solid #1a3355;
}
.sirene-type h4 {
  color: var(--text-heading); margin: 0 0 4px !important;
}
.sirene-desc { color: var(--text-secondary) !important; }
.sirene-action { color: var(--text-primary) !important; margin-top: 4px !important; }

/* ===== SETTINGS ===== */
.settings-section {
  margin-bottom: 20px;
}
.settings-section h3 {
  font-family: var(--font-heading);
  font-size: 1rem; font-weight: 700;
  color: var(--text-heading); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* ===== ADD BUTTON (FAB) ===== */
.fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--forest-mid); border: none;
  color: var(--text-heading); font-size: 1.5rem;
  cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; z-index: 100;
}
.fab:hover { background: var(--moss); transform: scale(1.05); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 2rem;
  color: var(--text-tertiary); font-size: .85rem;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .evac-grid { grid-template-columns: 1fr 1fr; }
  .header-title { font-size: 1.15rem; }
  .content { padding: 1rem .75rem 6rem; }
}
