/* B-TAX 企業版現代商務風格樣式表 */
:root {
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", "微軟正黑體", sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header & Navbar */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.nav-brand .badge-ent {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-basic { background: #e2e8f0; color: #475569; }
.badge-pro { background: #dbeafe; color: #1e40af; }
.badge-enterprise { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-admin { background: #fee2e2; color: #991b1b; }

/* Main Container */
.container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* Card & Panels */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Auth Modal / Box */
.auth-box {
  max-width: 460px;
  margin: 2.5rem auto;
  background: #ffffff;
  padding: 2.25rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transition: max-width 0.2s ease;
}

.auth-box.auth-box-wide {
  max-width: 620px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

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

.captcha-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.captcha-img {
  height: 48px;
  width: 160px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f1f5f9;
  cursor: pointer;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.hub-card {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.hub-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.hub-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.lock-tag {
  display: inline-block;
  font-size: 0.72rem;
  background: #f1f5f9;
  color: #475569;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  font-weight: 500;
}

.admin-edit-tag {
  display: inline-block;
  font-size: 0.72rem;
  background: #dcfce7;
  color: #166534;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  font-weight: 600;
}

.period-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.period-chip:hover {
  background: #dbeafe;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.form-control:disabled {
  background-color: #f1f5f9;
  cursor: not-allowed;
  color: #94a3b8;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.form-hint.error {
  color: var(--danger);
  font-weight: 500;
}

.form-hint.success {
  color: var(--success);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-google {
  background-color: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  width: 100%;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.1);
}
.btn-google:hover {
  background-color: #f8f9fa;
  border-color: #c6c9cc;
}

.btn-danger {
  background-color: #fee2e2;
  color: #b91c1c;
}
.btn-danger:hover {
  background-color: #fecaca;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.divider::before { margin-right: .5em; }
.divider::after { margin-left: .5em; }

/* Grid & Dashboard Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.25rem;
}
.stat-card .desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

th {
  background-color: #f8fafc;
  color: #475569;
  font-weight: 600;
}

tr:hover td {
  background-color: #f8fafc;
}

/* Alert Boxes */
.alert {
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.alert-warning {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.alert-danger {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.alert-info {
  background-color: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}
.alert-success {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 600px;
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

/* Hide helper */
.hidden {
  display: none !important;
}

/* 雲端上傳清單、OCR 進度與三態燈號 */
.upload-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.65rem;
}

.upload-file-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.upload-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  word-break: break-all;
}

.ocr-progress-box {
  margin-top: 0.9rem;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  border: 1px solid #cbd5e1;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #0d9488);
  transition: width 0.25s ease;
}

.lamp-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.lamp-green {
  background: #dcfce7;
  color: #166534;
}

.lamp-yellow {
  background: #fef3c7;
  color: #92400e;
}

.lamp-red {
  background: #fee2e2;
  color: #991b1b;
}
