/* ============================================================
   SMB Web Application Stylesheet
   Admin theme: dark sidebar + light content area
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:         #2563eb;
  --primary-hover:   #1d4ed8;
  --primary-light:   #eff6ff;
  --success:         #16a34a;
  --success-light:   #f0fdf4;
  --warning:         #d97706;
  --warning-light:   #fffbeb;
  --danger:          #dc2626;
  --danger-light:    #fef2f2;

  /* Sidebar */
  --sidebar-width:   220px;
  --sidebar-bg:      #0f172a;
  --sidebar-hover:   rgba(255,255,255,.07);
  --sidebar-active:  rgba(37,99,235,.35);
  --sidebar-text:    rgba(255,255,255,.65);
  --sidebar-text-hi: #ffffff;
  --sidebar-border:  rgba(255,255,255,.08);
  --sidebar-section: rgba(255,255,255,.35);

  /* Layout */
  --topbar-height:   52px;
  --bg:              #f1f5f9;
  --card-bg:         #ffffff;
  --border:          #e2e8f0;
  --text:            #0f172a;
  --text-secondary:  #64748b;
  --text-muted:      #94a3b8;

  /* Misc */
  --gray:            #64748b;
  --radius:          8px;
  --radius-lg:       12px;
  --shadow-sm:       0 1px 2px rgba(0,0,0,.05);
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:       0 4px 8px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:       0 12px 24px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.05);
  --transition:      0.18s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--primary-hover); }

img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
}

/* ── App Shell ────────────────────────────────────────────── */
.main-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--sidebar-text-hi);
  letter-spacing: -.02em;
}

.sidebar-brand-sub {
  font-size: .65rem;
  color: var(--sidebar-section);
  font-weight: 400;
  letter-spacing: .01em;
  line-height: 1;
  margin-top: .1rem;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .75rem 0;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 600;
  color: var(--sidebar-section);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 1rem .5rem .35rem;
  display: block;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-size: .875rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  white-space: nowrap;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: .75;
  transition: opacity var(--transition);
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-hi);
}
.sidebar-link:hover svg { opacity: 1; }

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-hi);
  font-weight: 500;
}
.sidebar-link.active svg { opacity: 1; }

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--sidebar-border);
  margin: .5rem 0;
}

.sidebar-footer {
  padding: .85rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: .65rem;
}

.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: .8125rem;
  color: var(--sidebar-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-section);
  padding: .25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.sidebar-logout-btn:hover {
  color: var(--danger);
  background: rgba(220,38,38,.12);
}

/* Hamburger (mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 300;
  background: var(--sidebar-bg);
  color: var(--sidebar-text-hi);
  border: none;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}

/* ── Page Wrapper ─────────────────────────────────────────── */
.page-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: 2rem 2.25rem 3rem;
  max-width: 1100px;
  width: 100%;
}

/* ── Page Title ───────────────────────────────────────────── */
.page-title {
  margin-bottom: 1.75rem;
}

.page-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.025em;
}

.page-title p {
  font-size: .9rem;
  color: var(--text-secondary);
  margin-top: .25rem;
}

/* ── Page Header (detail pages) ───────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1, .page-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

/* ── Container ────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ── Action Cards (home page) ─────────────────────────────── */
.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.action-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.action-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #bfdbfe;
  transform: translateY(-2px);
  color: var(--text);
}

.action-card-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.action-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.action-card p {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.action-card-cta {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: .25rem;
}

/* ── Info Grid ────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.info-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Section ──────────────────────────────────────────────── */
.section {
  margin-bottom: 1.75rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h3 {
  font-size: .9375rem;
  font-weight: 600;
}

.section-title {
  font-size: .9375rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ── Table ────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.table th {
  background: #f8fafc;
  text-align: left;
  padding: .65rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text);
}

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

.table tbody tr:hover td { background: #f8fafc; }

.table a { color: var(--primary); }
.table a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ── Status Badge ─────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-pending {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.status-pending::before { background: #f59e0b; }

.status-done, .status-signed {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.status-done::before, .status-signed::before { background: #22c55e; }

.status-canceled {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.status-canceled::before { background: #ef4444; }

/* ── Form ─────────────────────────────────────────────────── */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-label, .form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .4rem;
  letter-spacing: .01em;
}

.form-label .required { color: var(--danger); }

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

.form-control,
input[type="text"]:not(.login-input-wrap input),
input[type="password"]:not(.login-input-wrap input),
input[type="email"],
input[type="number"],
input[type="url"],
textarea,
select {
  display: block;
  width: 100%;
  padding: .6rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  line-height: 1.5;
}

.form-control::placeholder,
input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

.form-control:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-control:disabled { background: #f8fafc; opacity: .6; cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-error {
  display: none;
  font-size: .8rem;
  color: var(--danger);
  margin-top: .3rem;
}
.form-error.show { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Inline form (admin panels) */
.inline-form {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-form input {
  flex: 1;
  min-width: 160px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
  user-select: none;
}

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

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled, .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff !important;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff !important;
}

.btn-success {
  background: var(--success);
  color: #fff !important;
  border-color: var(--success);
}
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff !important; }

.btn-danger {
  background: var(--danger);
  color: #fff !important;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff !important; }

.btn-warning {
  background: var(--warning);
  color: #fff !important;
  border-color: var(--warning);
}
.btn-warning:hover { background: #b45309; border-color: #b45309; color: #fff !important; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #cbd5e1;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: #bfdbfe;
}
.btn-outline-primary:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

.btn-sm {
  padding: .3rem .7rem;
  font-size: .8125rem;
  border-radius: 6px;
}

.btn-lg {
  padding: .7rem 1.5rem;
  font-size: 1rem;
}

.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Recent Section (home page) ───────────────────────────── */
.recent-section {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.recent-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.recent-section-header h3 {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
}

.recent-section-body {
  padding: 0;
}

/* ── Navbar (legacy alias, not used in sidebar layout) ────── */
.navbar { display: none; }

/* ── File List ────────────────────────────────────────────── */
.file-list {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .875rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  transition: background var(--transition);
}

.file-item:hover { background: #f0f7ff; border-color: #bfdbfe; }

.file-item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  color: var(--gray);
}

.file-item-info { flex: 1; min-width: 0; }

.file-item-name {
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-meta {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-top: .1rem;
}

.file-item-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width .3s ease;
  position: relative;
}

.progress-bar-fill.animated::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.4) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.progress-bar.success .progress-bar-fill { background: var(--success); }
.progress-bar.danger  .progress-bar-fill { background: var(--danger); }

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: .35rem;
}

.progress-text { font-weight: 600; color: var(--text); }

/* ── Upload Zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: #fafbff;
  position: relative;
  outline: none;
}

.upload-zone:hover,
.upload-zone:focus,
.upload-zone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.upload-zone.dragover {
  border-style: solid;
  box-shadow: 0 0 0 4px rgba(37,99,235,.08);
}

.upload-zone-icon {
  font-size: 2.25rem;
  margin-bottom: .65rem;
  color: var(--gray);
  transition: color var(--transition);
}
.upload-zone:hover .upload-zone-icon,
.upload-zone.dragover .upload-zone-icon { color: var(--primary); }

.upload-zone-title {
  font-size: .9375rem;
  font-weight: 600;
  margin-bottom: .35rem;
}

.upload-zone-hint {
  font-size: .8125rem;
  color: var(--text-secondary);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.alert-icon { flex-shrink: 0; margin-top: .05rem; }

.alert-error   { background: var(--danger-light);  border-color: #fca5a5; color: #991b1b; }
.alert-success { background: var(--success-light); border-color: #86efac; color: #166534; }
.alert-info    { background: #eff6ff;              border-color: #93c5fd; color: #1e40af; }
.alert-warning { background: var(--warning-light); border-color: #fde68a; color: #92400e; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem .9rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: .875rem;
  font-weight: 500;
  min-width: 200px;
  max-width: 340px;
  pointer-events: auto;
  animation: toast-in .22s ease;
  border: 1px solid transparent;
}

.toast.removing { animation: toast-out .22s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(30px); }
}

.toast-success { background: var(--success-light); border-color: #86efac; color: #166534; }
.toast-error   { background: var(--danger-light);  border-color: #fca5a5; color: #991b1b; }
.toast-info    { background: #eff6ff;              border-color: #93c5fd; color: #1e40af; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: overlay-in .15s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: .6rem;
}

.modal-body {
  font-size: .9375rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .65rem;
}

/* ── Mono / Code ──────────────────────────────────────────── */
.mono {
  font-family: "SF Mono", "Fira Code", ui-monospace, Consolas, monospace;
  font-size: .8125em;
  background: #f1f5f9;
  padding: .1em .4em;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text);
  word-break: break-all;
}

code, pre {
  font-family: "SF Mono", "Fira Code", ui-monospace, Consolas, monospace;
}

/* ── Email Preview ────────────────────────────────────────── */
.email-preview {
  font-family: "SF Mono", "Fira Code", ui-monospace, Consolas, monospace;
  font-size: .8125rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  color: var(--text);
  max-height: 380px;
  overflow-y: auto;
}

.email-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}

.email-preview-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ── Detail List ──────────────────────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .5rem 1.5rem;
  font-size: .875rem;
}

.detail-label {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.detail-value {
  color: var(--text);
  word-break: break-word;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .35rem;
}

.empty-state-desc {
  font-size: .875rem;
  margin-bottom: 1.25rem;
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}

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

/* ── Tag / Chip ───────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  gap: .3rem;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8125rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border); font-size: .75rem; }
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* ── URL cell (table) ─────────────────────────────────────── */
.url-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── File upload progress (admin sign detail) ─────────────── */
.file-upload-progress {
  margin-top: .5rem;
}

/* ── Key value ────────────────────────────────────────────── */
.key-value {
  font-size: .8rem;
  max-width: 240px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Utilities ────────────────────────────────────────────── */
.text-center  { text-align: center !important; }
.text-right   { text-align: right !important; }
.text-left    { text-align: left !important; }

.text-primary   { color: var(--primary) !important; }
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--danger) !important; }
.text-warning   { color: var(--warning) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.font-bold   { font-weight: 700 !important; }
.font-medium { font-weight: 500 !important; }

.w-full  { width: 100% !important; }
.hidden  { display: none !important; }
.visible { display: block !important; }

.flex         { display: flex !important; }
.flex-between { display: flex !important; justify-content: space-between !important; align-items: center !important; }
.flex-center  { display: flex !important; align-items: center !important; justify-content: center !important; }
.flex-end     { display: flex !important; align-items: center !important; justify-content: flex-end !important; }
.items-center { align-items: center !important; }
.flex-wrap    { flex-wrap: wrap !important; }

.gap-1 { gap: .25rem !important; }
.gap-2 { gap: .5rem !important; }
.gap-3 { gap: .75rem !important; }
.gap-4 { gap: 1rem !important; }

.mt-1 { margin-top: .25rem !important; }
.mt-2 { margin-top: .5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 2rem !important; }

.mb-1 { margin-bottom: .25rem !important; }
.mb-2 { margin-bottom: .5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 2rem !important; }

.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }

.p-0 { padding: 0 !important; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overflow-hidden { overflow: hidden !important; }

/* ── Login Page ───────────────────────────────────────────── */
.login-body { background: #f1f5f9 !important; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f1f5f9 50%, #f0fdf4 100%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.09), 0 4px 12px rgba(0,0,0,.06);
  padding: 2.75rem 2.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  margin-bottom: .3rem;
}

.login-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

.login-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 8px;
  padding: .65rem 1rem;
  font-size: .875rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

.login-form { text-align: left; }

.login-field { margin-bottom: 1.1rem; }

.login-field label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .4rem;
  letter-spacing: .02em;
}

.login-input-wrap { position: relative; }

.login-input-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  pointer-events: none;
}

.login-input-wrap input {
  width: 100%;
  padding: .72rem .875rem .72rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9375rem;
  color: var(--text);
  background: #fdfdfe;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.login-input-wrap input::placeholder { color: var(--text-muted); }

.login-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: #fff;
}

.login-btn {
  width: 100%;
  margin-top: .5rem;
  padding: .8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.login-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

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

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .page-wrapper {
    margin-left: 0;
  }

  .page-content {
    padding: 1.25rem 1rem 2rem;
  }

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

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

  .modal { padding: 1.5rem; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }

  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; }

  thead { display: none; }
  tbody tr {
    display: flex;
    flex-direction: column;
    padding: .75rem 1rem;
    gap: .2rem;
    border-bottom: 1px solid var(--border);
  }
  td {
    padding: .1rem 0;
    display: flex;
    gap: .5rem;
    border-bottom: none !important;
  }
  td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .75rem;
    color: var(--text-secondary);
    min-width: 80px;
    flex-shrink: 0;
  }

  .login-card { padding: 2rem 1.5rem; border-radius: 12px; }
}

@media (max-width: 480px) {
  .page-title h1 { font-size: 1.25rem; }
  .info-grid { grid-template-columns: 1fr; }
  .upload-zone { padding: 2rem 1rem; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .btn, #toast-container { display: none !important; }
  .page-wrapper { margin-left: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  a { color: inherit; text-decoration: underline; }
}
