:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.07);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.10);
  --mc-green: #00a651;
  --mc-green-dark: #008c44;
  --mc-blue: #007bff;
  --mc-blue-dark: #0056b3;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); padding: 0 24px; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 24px;
  height: 64px; box-sizing: border-box;
}
.logo { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.5px; }
.user { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--muted); flex-wrap: nowrap; white-space: nowrap; }
.lang a, .logout {
  display: inline-flex; align-items: center; text-decoration: none;
  color: var(--muted); font-size: 0.85rem; padding: 8px 14px;
  border-radius: 10px; border: 1px solid #e5e7eb; transition: .2s;
  font-weight: 600; height: 36px; box-sizing: border-box;
}
.lang a:hover, .logout:hover { background: #f3f4f6; color: var(--text); }
.logout { color: #dc2626; border-color: #fecaca; background: #fff; }
.logout:hover { background: #fef2f2; }

/* Metro grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .container { padding: 16px; }
}
.tile {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 22px; border-radius: var(--radius); color: #fff;
  text-decoration: none; min-height: 140px; transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.tile .title { font-size: 1.1rem; font-weight: 700; }
.tile .count { font-size: 2rem; font-weight: 800; margin-top: 8px; }
.tile .hint { font-size: 0.8rem; opacity: 0.9; margin-top: 6px; }

/* Pastel but rich tile colors */
.tile.blue   { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.tile.green  { background: linear-gradient(135deg, #4ade80, #22c55e); }
.tile.purple { background: linear-gradient(135deg, #c084fc, #a855f7); }
.tile.gray   { background: linear-gradient(135deg, #9ca3af, #6b7280); }
.tile.orange { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.tile.teal   { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }
.tile.pink   { background: linear-gradient(135deg, #f9a8d4, #ec4899); }
.tile.white  { background: var(--card); color: var(--text); border: 1px solid #e5e7eb; }

/* Tables */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; overflow-y: hidden; }
table { width: 100%; min-width: max-content; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid #f3f4f6; white-space: nowrap; }
th { background: #f9fafb; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
tr:hover td { background: #fafafa; }
/* Always the last column — sticky so it's never scrolled off-screen behind
   a wide row (long badges, currency-suffixed amounts, etc.) with no visible
   scrollbar hinting there's more to the right. Needs its own background per
   row state since a sticky cell doesn't inherit the transparency the row
   backgrounds rely on — content scrolling underneath would otherwise show
   through. */
.actions {
  display: flex; gap: 8px;
  position: sticky; right: 0;
  background: var(--card);
  box-shadow: -6px 0 6px -6px rgba(0,0,0,0.15);
}
tr:hover td.actions { background: #fafafa; }
tr.check-group-normal td.actions { background: #f0f9ff; }
tr.check-group-alt td.actions { background: #f3e8ff; }

/* Buttons — vivid but flat, icons pop */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 10px; border: none; font-size: 0.85rem; cursor: pointer; text-decoration: none;
  font-weight: 600; transition: all .2s; box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.14); }
.btn:active { transform: translateY(0); }

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }

.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }

.btn-danger  { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }

.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid #e5e7eb; font-weight: 500; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px;
  font-size: 0.95rem; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
textarea { resize: vertical; min-height: 80px; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); padding: 20px; border-radius: var(--radius);
  box-shadow: var(--shadow); text-align: center;
}
.stat-card .num { font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-card .lbl { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

/* Badges */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700;
}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-coral { background: #ffe4e6; color: #9f1239; }

/* Toast */
.toast {
  position: fixed; top: 20px; right: 20px; background: #059669; color: #fff;
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow-hover); display: none; font-weight: 600;
}

/* Sort links */
.sort-link { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.sort-link:hover { color: var(--accent); }
.sort-arrow { font-size: 0.7rem; opacity: 0.6; }
.sort-link.active .sort-arrow { opacity: 1; color: var(--accent); }

/* Note cell */
.note-cell { max-width: 220px; font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.note-edit-form { display: flex; gap: 6px; align-items: center; }
.note-edit-form input { padding: 5px 8px; font-size: 0.85rem; border-radius: 8px; border: 2px solid #e5e7eb; }
.note-edit-form button { padding: 5px 10px; font-size: 0.8rem; }

/* Client note block */
.client-note { background: #f0f9ff; padding: 14px 18px; border-radius: 12px; border-left: 4px solid #3b82f6; margin-top: 14px; font-size: 0.92rem; color: #0369a1; }

/* Collapsible */
.collapsible { cursor: pointer; user-select: none; display:flex; align-items:center; gap:10px; }
.collapsible::before { content: '▼'; font-size:0.8rem; transition: transform .2s; display:inline-block; }
.collapsible.collapsed::before { transform: rotate(-90deg); }
.collapsible-body { overflow: hidden; transition: max-height .3s ease; }
.collapsible-body.hidden { max-height: 0; }
.purchase-form { background: var(--card); padding: 22px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; }

/* Lock message */
.lock-msg { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; background: #fffbeb; padding: 12px 16px; border-radius: 10px; border: 1px solid #fcd34d; }

/* Login */
.version-option { border: 2px solid #e5e7eb; border-radius: var(--radius); padding: 24px; cursor: pointer; transition: .2s; text-align: left; }
.version-option:hover { border-color: #93c5fd; }
.version-option.selected { border-color: #2563eb; background: #eff6ff; }


/* Pale pink-red delete buttons (mockup) */
.btn-del-soft {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid #ffcdd2;
  background: #ffebee; color: #c62828; font-size: 0.85rem; font-weight: 600;
  text-decoration: none; cursor: pointer; transition: all .2s;
}
.btn-del-soft:hover { background: #ffcdd2; color: #b71c1c; }

/* Locked client form */
.client-form-locked input,
.client-form-locked select,
.client-form-locked textarea {
    opacity: 0.7;
    pointer-events: none;
    filter: grayscale(0.4);
    background: #f8fafc;
    cursor: not-allowed;
}
.client-form-locked button[type="submit"] {
    display: none;
}


/* Ad banner */
.ad-banner {
  background: linear-gradient(135deg, var(--mc-green, #00a651), var(--mc-green-dark, #008c44));
  color: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 24px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 20px rgba(0, 166, 81, 0.35);
  min-height: 84px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
}


/* Checkbox groups in purchase history */
tr.check-group-normal td { background: #f0f9ff; }
tr.check-group-alt td { background: #f3e8ff; }
