/* app.css — Shop Tracker */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0efe9;
  --border: #e2e0d8;
  --border2: #ccc9be;
  --text: #1a1917;
  --text2: #6b6860;
  --text3: #9e9b92;
  --accent: #1a1917;
  --accent-fg: #ffffff;
  --green: #1a6641;
  --green-bg: #e8f5ee;
  --red: #b91c1c;
  --red-bg: #fef2f2;
  --amber: #92400e;
  --amber-bg: #fffbeb;
  --blue: #1e40af;
  --blue-bg: #eff6ff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
}

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }

/* ---- AUTH ---- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 1.5rem; }
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-sub { color: var(--text2); margin-bottom: 1.5rem; }
.auth-form .field { margin-bottom: 1rem; }
.auth-form label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }

/* ---- LAYOUT ---- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 1.25rem 0; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 100; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; padding: 0 1.25rem 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; }
.sidebar-brand svg { flex-shrink: 0; }
.nav-section { padding: 0 .75rem; margin-bottom: .25rem; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text3); padding: 0 .5rem; margin-bottom: .25rem; margin-top: .75rem; display: block; }
.nav-link { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text2); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s; }
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--accent); color: var(--accent-fg); }
.nav-link svg { flex-shrink: 0; opacity: .75; }
.nav-link.active svg { opacity: 1; }
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 9px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text3); }
.main { margin-left: 220px; flex: 1; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 1.5rem; max-width: 900px; }

/* ---- COMPONENTS ---- */
input, select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .12s, box-shadow .12s; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,25,23,.08); }
input::placeholder, textarea::placeholder { color: var(--text3); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all .12s; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface2); border-color: var(--border2); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { opacity: .85; background: var(--accent); }
.btn-danger { color: var(--red); border-color: #fca5a5; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 1.25rem; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.metric .m-label { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.metric .m-value { font-size: 22px; font-weight: 700; }
.metric.green .m-value { color: var(--green); }
.metric.red .m-value { color: var(--red); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red   { background: var(--red-bg); color: var(--red); }
.badge-blue  { background: var(--blue-bg); color: var(--blue); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text3); padding: 0 12px 8px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.field { margin-bottom: .85rem; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text2); margin-bottom: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 1rem; }
.alert-danger { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.alert-warn { background: var(--amber-bg); color: var(--amber); border: 1px solid #fcd34d; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #86efac; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.total-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; padding: 6px 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text3); font-size: 13px; }

.month-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 1.25rem; }
.month-bar label { font-size: 13px; color: var(--text2); white-space: nowrap; }
.month-bar select { max-width: 180px; width: auto; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; }
.hidden { display: none !important; }
#toast { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast-item { padding: 10px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; box-shadow: var(--shadow); animation: slideIn .2s ease; }
.toast-success { background: var(--green-bg); color: var(--green); border: 1px solid #86efac; }
.toast-error { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 680px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .field-row { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
