/* ==========================================
   KURO APSKAITA — Stiliai
   Mobile-first dark industrial design
   ========================================== */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232733;
  --border: #2d3142;
  --text: #e8eaf0;
  --text2: #8b90a5;
  --accent: #4dabf7;
  --accent-dim: rgba(77,171,247,0.12);
  --green: #51cf66;
  --green-dim: rgba(81,207,102,0.12);
  --red: #ff6b6b;
  --red-dim: rgba(255,107,107,0.12);
  --yellow: #fcc419;
  --yellow-dim: rgba(252,196,25,0.12);
  --radius: 14px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: 20px;
  overflow-x: hidden;
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* ---- HEADER ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,17,23,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.header h1 span { color: var(--accent); }
.header-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

/* ---- MONTH BAR ---- */
.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.month-bar button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.month-bar button:active { background: var(--accent-dim); }
.month-label {
  font-weight: 600;
  font-size: 16px;
  text-transform: capitalize;
}

/* ---- TABS ---- */
.tabs-wrap {
  padding: 12px 20px;
  background: var(--bg);
  position: sticky;
  top: 58px;
  z-index: 99;
  display: grid;
  gap: 8px;
}
.tabs {
  display: grid;
  gap: 4px;
}
.tabs-main {
  grid-template-columns: 1fr 1fr 1fr;
}
.tabs-secondary {
  grid-template-columns: 1fr 1fr;
}
.tab {
  min-width: 0;
  padding: 10px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.tab.tab-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- SUMMARY CARDS ---- */
.summary {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card.wide { grid-column: 1 / -1; }
.card-label {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.card-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 600;
}
.card-value.sm { font-size: 18px; }
.card-unit {
  font-size: 13px;
  color: var(--text2);
  font-weight: 400;
}
.card-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

.status-good { color: var(--green); }
.status-bad { color: var(--red); }
.status-warn { color: var(--yellow); }

.norm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}
.norm-badge.good { background: var(--green-dim); color: var(--green); }
.norm-badge.bad { background: var(--red-dim); color: var(--red); }

/* ---- SECTIONS ---- */
.section { padding: 0 20px 16px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-top: 16px;
}

/* ---- KM INPUTS ---- */
.km-row { display: flex; gap: 10px; }
.km-field {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.km-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.km-field label {
  display: block;
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.km-field input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  outline: none;
}
.km-field input::placeholder { color: var(--border); }

/* ---- ADD FORM ---- */
.add-form { padding: 0 0px 0px; }
.add-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-wrap {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input-wrap label {
  display: block;
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.input-wrap input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  outline: none;
}
.input-wrap input::placeholder { color: var(--border); }

/* Date input fix for dark theme */
input[type="date"] {
  color-scheme: dark;
}

.btn-add {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0 20px;
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  transition: opacity 0.15s;
}
.btn-add:active { opacity: 0.7; }

/* ---- RECEIPT LIST ---- */
.receipt-list { padding: 0 20px; }
.receipt-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.25s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.receipt-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.receipt-info { flex: 1; min-width: 0; }
.receipt-liters {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
}
.receipt-date {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.receipt-delete {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-dim);
  border: none;
  color: var(--red);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.receipt-delete:active { opacity: 0.6; }

/* ---- EMPTY STATE ---- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-text { font-size: 14px; }

/* ---- HISTORY ---- */
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 20px 8px;
}

#vignetteList .history-item {
  margin: 0 0 8px;
}

.history-month {
  font-weight: 600;
  font-size: 15px;
  text-transform: capitalize;
}
.history-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text2);
}
.history-stats .mono {
  color: var(--text);
  font-size: 13px;
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--green);
  color: #000;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: var(--text2);
  font-size: 13px;
  gap: 8px;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { display: none; }
html { scroll-behavior: smooth; }

/* ---- VINJETĖ ---- */
.global-alert {
  margin: 0 20px 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.global-alert.warn {
  background: var(--yellow-dim);
  color: var(--yellow);
  border-color: rgba(252,196,25,0.35);
}
.global-alert.bad {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(255,107,107,0.35);
}
.global-alert.good {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(81,207,102,0.35);
}
.tab.tab-alert {
  border-color: var(--yellow);
  color: var(--yellow);
}
.vignette-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
}
.vignette-top-row .section-title {
  margin-bottom: 0;
}
.btn-soft {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-soft:active {
  background: var(--accent-dim);
}
.vignette-card .card-sub {
  margin-top: 6px;
}
.vignette-note {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
}
.vignette-note.warn { color: var(--yellow); }
.vignette-note.bad { color: var(--red); }
.vignette-note.good { color: var(--green); }
.vignette-group {
  padding-bottom: 10px;
}
.vignette-group-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.vignette-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  gap: 12px;
}
.vignette-main {
  flex: 1;
  min-width: 0;
}
.vignette-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.v-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}
.v-badge.good {
  color: var(--green);
  background: var(--green-dim);
  border-color: rgba(81,207,102,0.2);
}
.v-badge.bad {
  color: var(--red);
  background: var(--red-dim);
  border-color: rgba(255,107,107,0.2);
}
.vignette-sub {
  margin-top: 6px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.45;
}
.vignette-price {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding-top: 1px;
}
@media (max-width: 480px) {
  .vignette-item {
    flex-direction: column;
  }
  .vignette-price {
    padding-top: 0;
  }
}
