/* ========================================
   OilBook — Design System
   ======================================== */

:root {
  /* Colors */
  --bg: #f4f3f1;
  --surface: #ffffff;
  --surface-alt: #f5f5f3;
  --surface-hover: #fafaf9;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.18);
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;

  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --green: #1D9E75;
  --green-light: #E1F5EE;
  --green-chip: #EAF3DE;
  --green-chip-text: #3B6D11;
  --red: #E24B4A;
  --red-light: #FCEBEB;
  --red-chip-text: #A32D2D;
  --orange-chip: #FAEEDA;
  --orange-chip-text: #854F0B;
  --purple: #6B3FA0;
  --purple-light: #F0EAF8;

  /* Typography */
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 20px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}


/* ========================================
   Reset & Base
   ======================================== */

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

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

.r { text-align: right; }
.c { text-align: center; }


/* ========================================
   Login Screen
   ======================================== */

.login-screen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 380px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  animation: fadeUp 0.5s var(--ease);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-hdr {
  padding: 32px 28px 22px;
  text-align: center;
}

.login-logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.login-divider {
  height: 1px;
  background: var(--border);
  margin: 0 0 20px;
}

.login-body {
  padding: 0 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-field label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

.login-field input {
  height: 44px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
  transition: border 0.15s var(--ease), box-shadow 0.15s var(--ease);
  background: var(--surface);
  color: var(--text-primary);
  width: 100%;
}

.login-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.1);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 42px;
}

.eye-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.eye-btn:hover {
  color: var(--text-secondary);
}

.login-err {
  font-size: 12px;
  color: var(--red);
  text-align: center;
  min-height: 18px;
  transition: opacity 0.2s;
}

.login-btn {
  height: 44px;
  background: var(--text-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s var(--ease), transform 0.1s;
}

.login-btn:hover {
  background: #333;
}

.login-btn:active {
  transform: scale(0.98);
}


/* ========================================
   App Screen
   ======================================== */

.app-screen {
  display: none;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeUp 0.4s var(--ease);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--border);
}

.top-bar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 0.5px solid var(--border);
}

.logout-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  border: 0.5px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  font-weight: 500;
}

.logout-btn:hover {
  background: var(--red-light);
  border-color: rgba(226, 75, 74, 0.3);
  color: var(--red-chip-text);
}


/* ========================================
   Loading Bar
   ======================================== */

.loading-bar {
  height: 3px;
  background: var(--blue-light);
  border-radius: 2px;
  margin-bottom: 16px;
  overflow: hidden;
  display: none;
}

.loading-bar.active {
  display: block;
}

.loading-bar-inner {
  height: 100%;
  width: 40%;
  background: var(--blue);
  border-radius: 2px;
  animation: slide 1s infinite linear;
}

@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}


/* ========================================
   Toast Notifications
   ======================================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--red);
}

.toast.success {
  background: var(--green);
}


/* ========================================
   Summary Strip
   ======================================== */

.strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.strip-item {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: box-shadow 0.2s var(--ease);
}

.strip-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.strip-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.strip-lbl {
  font-size: 12px;
  color: var(--text-muted);
}

.strip-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.strip-val {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.val-green { color: var(--green); }
.val-blue  { color: var(--blue); }
.val-red   { color: var(--red); }

.strip-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-alt);
}

.strip-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s var(--ease);
}


/* ========================================
   Form
   ======================================== */

.form-wrap {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--surface);
}

.form-header {
  padding: 13px 18px;
  border-bottom: 0.5px solid var(--border);
}

.form-header span {
  font-size: 13px;
  font-weight: 600;
}

.form-body {
  padding: 16px 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

input, select {
  height: 38px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text-primary);
  width: 100%;
  outline: none;
  font-family: var(--font-body);
  transition: border 0.15s var(--ease), box-shadow 0.15s var(--ease);
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.1);
}

input.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(226, 75, 74, 0.1);
  animation: shake 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

.preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.prev-item {
  padding: 10px 13px;
  border-right: 0.5px solid var(--border);
  background: var(--surface-hover);
}

.prev-item:last-child {
  border-right: none;
}

.prev-val {
  font-size: 14px;
  font-weight: 500;
  margin-top: 3px;
}

.form-footer {
  padding: 13px 18px;
  border-top: 0.5px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--surface-hover);
}

.btn {
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  font-weight: 500;
  border: 0.5px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-alt);
}

.btn:active {
  transform: scale(0.97);
}

.btn.accent {
  background: var(--text-primary);
  color: #fff;
  border-color: var(--text-primary);
}

.btn.accent:hover {
  background: #333;
}

.btn.danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn.danger:hover {
  background: #c0393a;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}


/* ========================================
   Two-Column Layout
   ======================================== */

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.box {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.box-head {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.box-body {
  padding: 4px 0;
}

.box-empty {
  padding: 18px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.chart-wrap {
  padding: 12px 16px;
}

.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.chart-bar-row:last-child {
  margin-bottom: 0;
}

.bar-label {
  font-size: 12px;
  font-weight: 500;
  width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  background: var(--surface-alt);
  border-radius: 4px;
  height: 22px;
  overflow: visible;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  min-width: 2px;
  transition: width 0.4s var(--ease);
}

.bar-fill span {
  font-size: 11px;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
}

.bar-val {
  font-size: 11px;
  color: var(--text-muted);
  width: 50px;
  text-align: right;
  flex-shrink: 0;
}

/* Agent/Payment rows */
.agent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  transition: background 0.1s;
}

.agent-row:last-child {
  border-bottom: none;
}

.agent-row:hover {
  background: var(--surface-hover);
}

.agent-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
}

.agent-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.pay-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.pay-dot.ok { background: var(--green); }
.pay-dot.no { background: var(--red); }

.pill-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pill {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.pill.ok { background: var(--green-chip); color: var(--green-chip-text); }
.pill.no { background: var(--red-light); color: var(--red-chip-text); }


/* ========================================
   Tables
   ======================================== */

.tbl-box {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: 16px;
}

.tbl-head {
  padding: 12px 18px;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
  background: var(--surface-hover);
}

td {
  padding: 10px 10px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-hover);
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}

.chip.d   { background: var(--blue-light); color: var(--blue); }
.chip.b92 { background: var(--green-chip); color: var(--green-chip-text); }
.chip.b95 { background: var(--orange-chip); color: var(--orange-chip-text); }
.chip.maz { background: #FAECE7; color: #993C1D; }
.chip.ker { background: var(--purple-light); color: var(--purple); }

.pay-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  font-family: var(--font-body);
}

.pay-toggle.ok {
  background: var(--green-chip);
  color: var(--green-chip-text);
  border-color: rgba(99, 153, 34, 0.3);
}

.pay-toggle.no {
  background: var(--red-light);
  color: var(--red-chip-text);
  border-color: rgba(226, 75, 74, 0.25);
}

.pay-toggle:hover {
  filter: brightness(0.95);
}

.del {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 15px;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s;
}

.del:hover {
  color: var(--red);
  background: var(--red-light);
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 28px;
  font-size: 13px;
  white-space: normal;
}


/* ========================================
   Mobile Deal Cards
   ======================================== */

#deals-mobile {
  display: none;
}

.deal-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.deal-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.deal-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.deal-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.deal-card-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.deal-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.deal-stat {
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 8px;
}

.deal-stat-lbl {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.deal-stat-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.deal-card-actions {
  display: flex;
  gap: 8px;
}

.deal-pay-btn {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
  border: 0.5px solid;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: all 0.15s;
}

.deal-pay-btn.ok {
  background: var(--green-chip);
  color: var(--green-chip-text);
  border-color: rgba(99, 153, 34, 0.3);
}

.deal-pay-btn.no {
  background: var(--red-light);
  color: var(--red-chip-text);
  border-color: rgba(226, 75, 74, 0.25);
}

.deal-del-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  background: transparent;
  color: #ccc;
  font-size: 16px;
  cursor: pointer;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: all 0.15s;
}

.deal-del-btn:hover {
  color: var(--red);
  background: var(--red-light);
}

.deals-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 28px;
  font-size: 13px;
}


/* ========================================
   Modal
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
  animation: fadeUp 0.2s var(--ease);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}


/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
  .app-screen {
    padding: 12px;
  }

  .strip {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .strip-val {
    font-size: clamp(13px, 4.5vw, 22px);
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .preview {
    grid-template-columns: 1fr;
  }

  .prev-item {
    border-right: none;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
  }

  .prev-item:last-child {
    border-bottom: none;
  }

  .cols {
    grid-template-columns: 1fr;
  }

  .top-bar-title {
    font-size: 14px;
  }

  .user-badge {
    display: none;
  }

  .btn {
    height: 42px;
    font-size: 14px;
  }

  .btn.accent {
    flex: 1;
  }

  #deals-desktop {
    display: none;
  }

  #deals-mobile {
    display: block;
  }
}

@media (max-width: 400px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
