/* ─── Reset & Variables ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* StrokieStorie palette */
  --orange: #FF7A1A;
  --pink: #FF3D7F;
  --magenta: #E91E63;
  --purple: #7B2CBF;
  --brand-gradient: linear-gradient(135deg, #FF7A1A 0%, #FF3D7F 50%, #7B2CBF 100%);

  /* Legacy variable names remapped so existing class names keep working */
  --green: #FF7A1A;       /* primary (orange) */
  --dark-green: #7B2CBF;  /* dark accent (purple) */
  --gold: #FF3D7F;        /* secondary accent (pink) */

  --bg: #FFFFFF;
  --white: #ffffff;
  --text: #1F2937;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.18);
  --tab-h: 82px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html {
  height: 100%;
  height: 100dvh;
}

body {
  height: 100%;
  height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 18px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Auth Screen ─────────────────────────────────── */
.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 24px) 24px calc(var(--sab) + 24px);
  z-index: 1000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-card {
  background: var(--white);
  border-radius: 24px;
  padding: 36px 28px;
  text-align: center;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  width: 250px;
  height: auto;
  object-fit: contain;
  margin-bottom: 18px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.moek-emoji {
  font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
  -webkit-background-clip: initial;
  background-clip: initial;
  background: none;
  color: initial;
  -webkit-text-fill-color: initial;
}

.auth-message {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  margin: 4px 8px 22px;
  min-height: 28px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--dark-green);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.auth-desc {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 28px;
}

/* Login form inside auth card */
#login-form .form-group { margin-bottom: 14px; text-align: left; }
#login-form .form-label { color: var(--text-muted); }
#login-form .form-input { background: var(--bg); }

.login-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #c0392b;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  margin-bottom: 14px;
  text-align: left;
}

/* Drive connect banner */
.drive-connect-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e8f4fd;
  border: 1px solid #90caf9;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  color: #1565c0;
  margin-bottom: 16px;
}

.banner-link {
  margin-left: auto;
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

/* ─── App Shell — full-height flex column ──────────── */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--sat);
  padding-bottom: var(--sab);
  overflow: hidden;
}

/* ─── Tab Bar ─────────────────────────────────────── */
.tab-bar {
  flex: 0 0 var(--tab-h);
  display: flex;
  background: var(--brand-gradient);
  border-bottom: 2px solid rgba(255,255,255,0.18);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.tab-btn { color: rgba(255,255,255,0.75); }
.tab-btn.active { color: #fff; }

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: #fff;
  border-radius: 3px 3px 0 0;
}

.tab-icon {
  width: 30px;
  height: 30px;
}

/* ─── Tab Content — grows to fill remaining space ──── */
.tab-content {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Each panel fills the content area, hidden by default */
.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  visibility: hidden;
  pointer-events: none;
  /* Do NOT use display:none — keeps scroll position */
}

.tab-panel.active {
  visibility: visible;
  pointer-events: auto;
}

.panel-inner {
  padding: 16px 16px 120px;
  max-width: 600px;
  margin: 0 auto;
}

/* ─── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  min-height: 56px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.96); opacity: 0.85; }

.btn-primary  { background: var(--orange); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--purple); border: 2px solid var(--purple); }
.btn-gold     { background: var(--purple); color: var(--white); }
.btn-danger   { background: #c0392b; color: #fff; }
.btn-large    { padding: 16px 28px; font-size: 18px; min-height: 60px; }
.btn-full     { width: 100%; }

/* ─── Panel Header ────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 16px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.btn-signout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}
.btn-signout:active { opacity: 0.6; }

.header-logo {
  width: 96px;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.header-message {
  flex: 1;
  font-family: 'Pacifico', cursive;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.55;
  padding: 4px 0 8px 22px;
  border-left: 3px solid var(--purple);
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  min-height: 32px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark-green);
  line-height: 1.1;
}

.header-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-slogan {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
  font-style: italic;
}

.auth-screen .auth-title {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ─── Summary Card ────────────────────────────────── */
.summary-card {
  background: var(--brand-gradient);
  border-radius: 20px;
  padding: 22px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.summary-month {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
  text-align: center;
}

.summary-stats {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}

.stat { text-align: center; }
.summary-stats .stat:first-child { flex: 0 0 29%; }
.summary-stats .stat:last-child  { flex: 1; }

.stat-num {
  display: block;
  font-size: 30px;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-divider {
  width: 1px;
  height: 44px;
  background: rgba(255,255,255,0.4);
  flex-shrink: 0;
}

/* ─── Offline Banner ──────────────────────────────── */
.offline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  color: #664d03;
  margin-bottom: 16px;
}

/* ─── Section Title ───────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark-green);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
  text-align: left;
}

/* ─── Home Tab Layout (fixed header + scrollable list) ── */
#tab-home {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.home-fixed {
  flex-shrink: 0;
  background: var(--bg);
}

.home-fixed-inner {
  padding: 16px 16px 0;
  max-width: 600px;
  margin: 0 auto;
}

.home-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.home-scroll-inner {
  padding: 12px 16px 120px;
  max-width: 600px;
  margin: 0 auto;
}

/* ─── Scans List ──────────────────────────────────── */
.scans-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ─── Empty State ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 14px; display: block; margin-left: auto; margin-right: auto; opacity: 0.4; }
.empty-state p { font-size: 17px; line-height: 1.6; }

/* ─── Sign Out tab button ─────────────────────────── */
.tab-signout { color: rgba(255,255,255,0.4); }
.tab-signout:active { opacity: 0.6; }

/* ─── Reports Tab ─────────────────────────────────── */
.reports-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--purple);
  margin-top: 16px;
  margin-bottom: 10px;
}

.reports-sub {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 40px;
  line-height: 1.5;
}

.reports-selects {
  display: flex;
  gap: 14px;
  margin-bottom: 40px;
}

.reports-select {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.reports-summary-card {
  background: var(--brand-gradient);
  border-radius: var(--radius);
  padding: 28px 20px;
  margin-bottom: 48px;
}

.reports-summary-card .summary-stats { justify-content: center; }
.reports-summary-card .stat-num { color: #fff; }
.reports-summary-card .stat-label { color: rgba(255,255,255,0.85); }

/* ─── Camera View ─────────────────────────────────── */
.camera-view {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 20;
  display: none;
}

.camera-view.active { display: block; }

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.edge-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.camera-ui {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 2;
}

.camera-hint {
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
}

.camera-hint.detected { background: rgba(45,90,61,0.88); }

.capture-btn {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 3px solid #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.capture-btn:active { transform: translateX(-50%) scale(0.88); }

.capture-btn-inner {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #fff;
}

.camera-done-btn {
  position: absolute;
  top: 20px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border-radius: 24px;
  background: var(--orange);
  color: #fff;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  -webkit-tap-highlight-color: transparent;
}
.camera-done-btn:active { transform: scale(0.96); opacity: 0.9; }
.camera-done-btn.hidden { display: none; }

.camera-close {
  position: absolute;
  top: 20px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Capture Options ─────────────────────────────── */
.capture-options {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 20;
  overflow: hidden;
}

.crop-editor-wrap {
  position: absolute;
  inset: 0;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.crop-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  touch-action: none;
}

.capture-question {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.capture-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.7);
  z-index: 2;
}

.capture-actions .btn { flex: 1; }

/* ─── Processing ──────────────────────────────────── */
.processing-view {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spinner {
  width: 52px;
  height: 52px;
  border: 5px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small { width: 28px; height: 28px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.processing-text { font-size: 20px; font-weight: 600; color: var(--dark-green); }
.processing-sub { font-size: 15px; color: var(--text-muted); }

/* ─── Confirm View ────────────────────────────────── */
.confirm-view {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 20;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.confirm-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.confirm-image-col {
  background: var(--dark-green);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  flex-shrink: 0;
}

.confirm-preview-img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: block;
}

.confirm-form-col {
  flex: 1;
}

.confirm-title { font-size: 22px; font-weight: 700; color: var(--dark-green); margin-bottom: 6px; }
.confirm-sub { font-size: 15px; color: var(--text-muted); margin-bottom: 18px; }

/* ─── Receipt Form Card ───────────────────────────── */
.receipt-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.receipt-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.form-group { margin-bottom: 12px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.form-input, .form-select {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 17px;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  min-height: 52px;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--green);
  background: var(--white);
}

.input-warn { border-color: #e07b39 !important; background: #fff8f4 !important; }
.input-warn-msg { font-size: 13px; color: #c0550a; margin-top: 5px; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding-bottom: 40px;
}

/* ─── Scan Start Screen ───────────────────────────── */
.scan-start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.scan-start-inner { text-align: center; max-width: 320px; }

.scan-icon-wrap {
  width: 96px;
  height: 96px;
  background: rgba(45,90,61,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.scan-start-inner h2 { font-size: 24px; font-weight: 700; color: var(--dark-green); margin-bottom: 10px; }
.scan-start-inner p { font-size: 16px; color: var(--text-muted); line-height: 1.6; margin-bottom: 28px; }

/* ─── Drive Tab ───────────────────────────────────── */
.drive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 12px;
  flex-wrap: wrap;
}

.drive-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 14px;
  flex: 1;
}

.breadcrumb-item { color: var(--text-muted); cursor: pointer; padding: 2px 4px; }
.breadcrumb-item:not(.active):active { color: var(--green); }
.breadcrumb-item.active { color: var(--dark-green); font-weight: 600; pointer-events: none; }
.breadcrumb-sep { color: var(--border); }

.drive-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 40px; }

/* ─── Drive Connect pane (when not yet authorised) ─── */
.drive-connect-pane {
  text-align: center;
  padding: 24px 16px 40px;
  max-width: 440px;
  margin: 0 auto;
}
.drive-connect-icon {
  width: 96px;
  height: 96px;
  background: rgba(123,44,191,0.10);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.drive-connect-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 12px;
}
.drive-connect-text {
  font-size: 16px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 24px;
}
.drive-connect-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 18px;
}

/* ─── Connected status bar ─── */
.drive-connected-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(123,44,191,0.06);
  border: 1px solid rgba(123,44,191,0.2);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.drive-connected-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.drive-connected-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10B981;
  flex-shrink: 0;
}
.drive-connected-email {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drive-disconnect-btn {
  background: none;
  border: 1px solid var(--purple);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.drive-disconnect-btn:active { opacity: 0.6; }

.drive-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  min-height: 64px;
  -webkit-tap-highlight-color: transparent;
}

.drive-item:active { opacity: 0.75; }

.drive-item-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drive-item-icon.folder { background: rgba(201,168,76,0.15); }
.drive-item-icon.file   { background: rgba(45,90,61,0.1); }

.drive-item-info { flex: 1; min-width: 0; }
.drive-item-name { font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drive-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.drive-item-arrow { color: var(--border); flex-shrink: 0; }

.drive-item-share {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(45,90,61,0.08);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.drive-item-share:active { opacity: 0.6; }

/* ─── Loading State ───────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ─── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--sab) + 90px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--dark-green);
  color: var(--white);
  padding: 13px 22px;
  border-radius: 28px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 500;
  max-width: calc(100vw - 40px);
  text-align: center;
  white-space: pre-wrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error   { background: #c0392b; }
.toast.success { background: var(--green); }

/* ─── Success Overlay ─────────────────────────────── */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31,41,55,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 24px;
}

.success-card {
  background: var(--white);
  border-radius: 24px;
  padding: 40px 28px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.success-icon {
  width: 80px;
  height: 80px;
  background: rgba(45,90,61,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.success-card h2 { font-size: 26px; font-weight: 800; color: var(--dark-green); margin-bottom: 8px; }
.success-card p  { font-size: 16px; color: var(--text-muted); line-height: 1.5; margin-bottom: 24px; }
.success-card .btn + .btn { margin-top: 10px; }

/* ─── Scan Cards (Home Tab Recent Scans — list rows) ─ */
.scan-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  min-height: 64px;
  -webkit-tap-highlight-color: transparent;
}
.scan-card:active { opacity: 0.75; }
.scan-card-info {
  flex: 1;
  min-width: 0;
}
.scan-card-merchant {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scan-card-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.scan-card-amount {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
}

/* ─── Delete Modal ────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: var(--white);
  border-radius: 20px;
  padding: 28px 24px 20px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-msg {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn { flex: 1; }

.modal-actions-stack {
  flex-direction: column;
}
.modal-actions-stack .btn { flex: none; }

.modal-title {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ─── Drive item delete button ─────────────────────── */
.drive-item-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  min-height: 56px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  color: #c0392b;
  opacity: 0.75;
}
.drive-item-delete:active { opacity: 0.4; }

/* ─── PDF Viewer Overlay ──────────────────────────── */
.pdf-viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: #525659;
}

.pdf-viewer.hidden { display: none !important; }

.pdf-viewer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-gradient);
  padding: calc(var(--sat) + 10px) 12px 10px;
  border-bottom: 2px solid rgba(255,255,255,0.18);
}

.pdf-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
  flex-shrink: 0;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.pdf-back-btn:active { opacity: 0.6; }

.pdf-viewer-title {
  flex: 1;
  color: white;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.pdf-share-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.pdf-share-btn:active { opacity: 0.6; }

.pdf-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.85;
}
.pdf-delete-btn:active { opacity: 0.5; }

.pdf-canvas-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: #525659;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0 24px;
}

.pdf-canvas-container canvas {
  display: block;
  max-width: 100%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 1;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  padding: 40px;
}

/* ─── Tablet two-column layout (≥768px) ──────────── */
@media (min-width: 768px) {
  /* App shell: side tab bar instead of bottom bar */
  .app {
    flex-direction: row;
  }

  .tab-bar {
    flex: 0 0 80px;
    flex-direction: column;
    height: 100%;
    border-bottom: none;
    border-right: 2px solid rgba(255,255,255,0.18);
    padding: calc(var(--sat) + 8px) 0 calc(var(--sab) + 8px);
  }

  .tab-btn {
    flex: 0 0 72px;
    font-size: 10px;
  }

  .tab-btn.active::after {
    top: 15%;
    bottom: 15%;
    left: auto;
    right: 0;
    width: 3px;
    height: auto;
    border-radius: 3px 0 0 3px;
  }

  .tab-content {
    flex: 1;
  }

  /* Home tab: widen inner containers on tablet */
  .home-fixed-inner,
  .home-scroll-inner {
    max-width: none;
    padding-left: 28px;
    padding-right: 28px;
  }

  .home-fixed-inner { padding-top: 24px; }
  .home-scroll-inner { padding-bottom: 40px; }

  /* Scan confirm: image left + form right */
  .confirm-inner {
    flex-direction: row;
    height: 100%;
    overflow: hidden;
  }

  .confirm-image-col {
    flex: 0 0 45%;
    max-height: 100%;
    overflow: hidden;
  }

  .confirm-preview-img {
    max-height: calc(100vh - 64px);
  }

  .confirm-form-col {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 28px 40px;
  }

  .confirm-actions { flex-direction: row; }
  .confirm-actions .btn { flex: 1; }

  /* Drive/panels general */
  .panel-inner { padding: 24px 28px 40px; max-width: none; }
}
