:root {
  --brand: #1a56db;
  --brand-dark: #1e429f;
  --danger: #e02424;
  --success: #057a55;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.navbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.navbar-brand { font-size: 1.1rem; font-weight: 700; color: var(--brand); }
.navbar-right { display: flex; align-items: center; gap: 16px; }
.navbar-user { font-size: .875rem; color: var(--gray-600); }

main { flex: 1; max-width: 960px; margin: 32px auto; padding: 0 20px; width: 100%; }

/* ── Auth pages ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
}

.auth-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 { font-size: 1.5rem; margin-bottom: 8px; }
.auth-card p  { font-size: .9rem; color: var(--gray-600); margin-bottom: 24px; }

.auth-toggle { font-size: .875rem; color: var(--gray-600); margin-top: 16px; text-align: center; }
.auth-toggle a { color: var(--brand); cursor: pointer; }

/* ── Form elements ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password], input[type=file], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  outline: none;
  transition: border-color .15s;
  background: #fff;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--brand-dark); }
.btn-outline  { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-outline:hover:not(:disabled)  { background: var(--gray-50); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-google   { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-200); width: 100%; margin-top: 8px; }
.btn-google:hover { background: var(--gray-50); }
.btn-block    { width: 100%; }
.btn-sm       { padding: 6px 14px; font-size: .8rem; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--gray-400); font-size: .8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 16px; }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.upload-zone.drag-over { border-color: var(--brand); background: #eff6ff; }
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone p { color: var(--gray-600); font-size: .9rem; }
.upload-zone .file-name { font-weight: 600; color: var(--gray-800); margin-top: 8px; }

/* ── Progress ── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 99px;
  transition: width .3s;
}

/* ── Usage badge ── */
.usage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.usage-item { text-align: center; }
.usage-number { font-size: 2rem; font-weight: 700; color: var(--brand); }
.usage-label  { font-size: .8rem; color: var(--gray-600); }
.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.plan-free    { background: var(--gray-100); color: var(--gray-600); }
.plan-basic   { background: #fef3c7; color: #92400e; }
.plan-premium { background: #ede9fe; color: #5b21b6; }

/* ── History table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; padding: 10px 12px; font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-error   { background: #fee2e2; color: #991b1b; }

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Plans ── */
.plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  position: relative;
}
.plan-card.current { border-color: var(--brand); }
.plan-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.plan-price { font-size: 1.8rem; font-weight: 700; margin: 12px 0; }
.plan-price small { font-size: .9rem; font-weight: 400; color: var(--gray-600); }
.plan-limit { font-size: .85rem; color: var(--gray-600); margin-bottom: 20px; }
.current-tag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--brand); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 2px 12px; border-radius: 99px;
}

/* ── Misc ── */
.hidden { display: none !important; }
.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.flex  { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: .875rem; }
.text-gray { color: var(--gray-600); }
.font-bold { font-weight: 700; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .usage-grid { grid-template-columns: repeat(3, 1fr); }
  .plans-grid { grid-template-columns: 1fr; }
  main { margin: 16px auto; }
  .auth-card { padding: 24px; }
}
