@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

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

:root {
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --primary-light: #EEF2FF;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #6366F1;
  --info-light: #E0E7FF;

  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.1), 0 8px 10px rgba(0,0,0,.06);

  --sidebar-width: 260px;
}

body {
  font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Login ---- */
#login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1e1b4b 50%, var(--gray-900) 100%);
}
.login-card {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  padding: 2.5rem; width: 100%; max-width: 420px;
}
.login-card h1 {
  font-size: 1.5rem; font-weight: 700; color: var(--gray-900);
  font-family: 'Fira Code', monospace; letter-spacing: -.025em;
  margin-bottom: .25rem;
}
.login-card p { color: var(--gray-500); margin-bottom: 1.75rem; font-size: .875rem; }
.login-error { color: var(--danger); font-size: .875rem; margin-bottom: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .375rem;
  color: var(--gray-700);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: .5rem .75rem; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm); font-size: .875rem; outline: none;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

/* ---- Buttons ---- */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .5rem 1rem; border-radius: var(--radius-sm); font-size: .875rem;
  font-weight: 500; cursor: pointer; border: none;
  transition: all .15s ease; text-decoration: none; gap: .375rem;
  line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 8px rgba(99,102,241,.35); }
.btn-secondary {
  background: #fff; color: var(--gray-700); border: 1.5px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); box-shadow: 0 2px 8px rgba(239,68,68,.35); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-block { width: 100%; }

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

#sidebar {
  width: var(--sidebar-width); background: var(--gray-900); color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  height: 100vh; overflow-y: auto; z-index: 100;
}
#sidebar .brand {
  padding: 1.25rem 1.25rem .75rem;
  font-family: 'Fira Code', monospace; font-size: 1.125rem; font-weight: 700;
  letter-spacing: -.025em;
  display: flex; align-items: center; gap: .625rem;
}
#sidebar .brand svg { width: 1.5rem; height: 1.5rem; color: var(--primary); flex-shrink: 0; }
#sidebar .brand-sub {
  font-size: .6875rem; font-weight: 400; color: var(--gray-500);
  font-family: 'Fira Sans', sans-serif; letter-spacing: .05em;
  text-transform: uppercase; margin-top: -2px;
}
#sidebar nav { flex: 1; padding: .5rem 0; }
#sidebar nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .625rem 1.25rem; color: var(--gray-400); text-decoration: none;
  font-size: .875rem; font-weight: 500; transition: all .15s;
  margin: 1px .5rem; border-radius: var(--radius-sm); position: relative;
}
#sidebar nav a svg {
  width: 1.125rem; height: 1.125rem; flex-shrink: 0;
  color: var(--gray-500); transition: color .15s;
}
#sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#sidebar nav a:hover svg { color: var(--primary); }
#sidebar nav a.active {
  background: rgba(99,102,241,.15); color: #fff;
}
#sidebar nav a.active svg { color: var(--primary); }
#sidebar nav a.active::before {
  content: ''; position: absolute; left: -.5rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 1.25rem; background: var(--primary); border-radius: 0 3px 3px 0;
}
#sidebar .sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
#sidebar .sidebar-footer .user-info {
  font-size: .8125rem; color: var(--gray-400); margin-bottom: .375rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#sidebar .sidebar-footer a {
  color: var(--gray-500); text-decoration: none; font-size: .8125rem;
  transition: color .15s;
}
#sidebar .sidebar-footer a:hover { color: #fff; }

#main-content {
  margin-left: var(--sidebar-width); flex: 1;
  padding: 1.5rem 2rem; min-height: 100vh;
  max-width: 1440px;
}

/* ---- Page header ---- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem;
}
.page-header h2 {
  font-size: 1.375rem; font-weight: 700;
  color: var(--gray-900); letter-spacing: -.02em;
}

/* ---- Section card (used in detail pages) ---- */
.section-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.section-card + .section-card { margin-top: 1.25rem; }
.section-card-header {
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--gray-200);
  font-weight: 600; font-size: .875rem; color: var(--gray-900);
  display: flex; align-items: center; justify-content: space-between;
}
.section-card-body { padding: 1.5rem; }
.section-card-body-compact { padding: 1rem 1.5rem; }

/* ---- Detail grid (2-column field layout) ---- */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2rem;
}
.detail-field {}
.detail-label {
  font-size: .75rem; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem;
}
.detail-value {
  font-size: .875rem; color: var(--gray-900);
}
.detail-value-mono {
  font-family: 'Fira Code', monospace; font-size: .8125rem;
  color: var(--gray-600);
}

/* ---- Table ---- */
.table-wrapper {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.table-toolbar {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}
.table-toolbar input, .table-toolbar select {
  padding: .4rem .625rem; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm); font-size: .8125rem; outline: none;
  font-family: inherit; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.table-toolbar input:focus, .table-toolbar select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

table { width: 100%; border-collapse: collapse; }
thead { background: var(--gray-50); }
thead th {
  text-align: left; padding: .75rem 1rem; font-size: .75rem;
  font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td { padding: .75rem 1rem; font-size: .875rem; border-bottom: 1px solid var(--gray-100); }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: .375rem; flex-wrap: nowrap; }
.actions .btn-sm { white-space: nowrap; }

.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--gray-400);
  font-size: .875rem;
}

/* ---- Pagination ---- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: .25rem; padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
}
.pagination button {
  padding: .375rem .75rem; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm); background: #fff; cursor: pointer;
  font-size: .8125rem; color: var(--gray-700); font-weight: 500;
  transition: all .15s;
}
.pagination button:hover:not(:disabled) {
  background: var(--gray-50); border-color: var(--gray-400);
}
.pagination button:disabled { opacity: .35; cursor: not-allowed; }
.pagination button.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.pagination .info {
  font-size: .8125rem; color: var(--gray-500);
  margin-left: .75rem; white-space: nowrap;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--gray-900); }
.modal-header button {
  background: none; border: none; font-size: 1.25rem; cursor: pointer;
  color: var(--gray-400); padding: .25rem; border-radius: var(--radius-sm);
  transition: all .15s; line-height: 1;
}
.modal-header button:hover { background: var(--gray-100); color: var(--gray-600); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .5rem; padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-error { color: var(--danger); font-size: .8125rem; margin-top: .5rem; }
.form-success { color: var(--success); font-size: .8125rem; margin-top: .5rem; }
.form-hint { font-size: .75rem; color: var(--gray-500); margin-top: .25rem; }

/* ---- Back link ---- */
.back-link {
  font-size: .8125rem; color: var(--primary); text-decoration: none;
  display: inline-flex; align-items: center; gap: .25rem;
  margin-bottom: .375rem; transition: color .15s;
}
.back-link:hover { color: var(--primary-hover); }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: .125rem .5rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 600; line-height: 1.4;
}
.badge-success { background: var(--success-light); color: #065F46; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: var(--info-light); color: #3730A3; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ---- Loading ---- */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.spinner {
  width: 1.5rem; height: 1.5rem;
  border: 3px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Dashboard cards ---- */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}
.dash-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 1.25rem;
  display: flex; flex-direction: column; gap: .5rem;
  position: relative; overflow: hidden;
  cursor: pointer; transition: all .2s ease;
  border: 1.5px solid transparent;
}
.dash-card:hover {
  box-shadow: var(--shadow-lg); transform: translateY(-2px);
  border-color: var(--gray-200);
}
.dash-card-icon {
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.dash-card-icon svg { width: 1.125rem; height: 1.125rem; }
.dash-card--blue .dash-card-icon { background: #E0E7FF; color: #4338CA; }
.dash-card--green .dash-card-icon { background: #D1FAE5; color: #059669; }
.dash-card--amber .dash-card-icon { background: #FEF3C7; color: #D97706; }
.dash-card--purple .dash-card-icon { background: #EDE9FE; color: #7C3AED; }
.dash-card--cyan .dash-card-icon { background: #CFFAFE; color: #0891B2; }
.dash-card--rose .dash-card-icon { background: #FFE4E6; color: #E11D48; }
.dash-card-label {
  font-size: .75rem; text-transform: uppercase; color: var(--gray-500);
  font-weight: 600; letter-spacing: .05em;
}
.dash-card-value {
  font-size: 1.75rem; font-weight: 700; color: var(--gray-900);
  font-family: 'Fira Code', monospace;
}

/* ---- Deleted row ---- */
tr.row-deleted td { opacity: .45; }

/* ---- ID cell ---- */
.cell-id {
  font-family: 'Fira Code', monospace; font-size: .8125rem;
  color: var(--gray-500); cursor: pointer;
  transition: color .15s;
}
.cell-id:hover { color: var(--primary); }

/* ---- Ingredient highlight ---- */
.ingredient-match {
  background: #FEF3C7; padding: .0625rem .125rem;
  border-radius: 3px; cursor: default; white-space: nowrap;
}
.ingredient-add-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 2px;
  background: var(--success); color: #fff; border-radius: 50%;
  font-size: .6875rem; font-weight: 700; line-height: 1;
  cursor: pointer; vertical-align: middle;
  transition: background .15s;
}
.ingredient-add-badge:hover { background: #059669; }
.ingredient-add-badge.added { background: var(--success); cursor: default; }

/* ---- Image grid ---- */
.image-card { transition: box-shadow .15s; }
.image-card:hover { box-shadow: var(--shadow); }

/* ---- Order item rows ---- */
.order-item-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem 0;
}
.order-item-row + .order-item-row { border-top: 1px solid var(--gray-100); }
#f-items-wrapper { margin-top: .5rem; }

/* ---- Tabs ---- */
.tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50); padding: 0 1.5rem; overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: .875rem 1.25rem; font-size: .8125rem; font-weight: 500;
  color: var(--gray-500); background: none; border: none;
  cursor: pointer; white-space: nowrap; position: relative;
  transition: color .15s; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active {
  color: var(--primary); border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Utility: label style for inline field-value pairs (detail pages) ---- */
.field-label {
  font-size: .75rem; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .04em; display: block;
  margin-bottom: .125rem;
}
.field-value {
  font-size: .875rem; color: var(--gray-900);
}
.field-value-mono {
  font-family: 'Fira Code', monospace; font-size: .8125rem;
  color: var(--gray-600);
}

/* ---- Table scroll wrapper ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Sidebar toggle for mobile ---- */
.sidebar-toggle {
  display: none; position: fixed; top: .75rem; left: .75rem;
  z-index: 200; background: var(--gray-900); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: .5rem; cursor: pointer;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  #sidebar {
    width: 260px; transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  #sidebar.open { transform: translateX(0); }
  #main-content {
    margin-left: 0; padding: 1rem;
  }
  .sidebar-toggle { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .dash-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .page-header { flex-direction: column; align-items: stretch; gap: .75rem; }
  .page-header h2 { font-size: 1.125rem; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .actions { flex-wrap: wrap; }
  .pagination { flex-wrap: wrap; justify-content: center; }
  .pagination .info { width: 100%; text-align: center; margin-left: 0; margin-top: .25rem; }
  .tab-btn { padding: .75rem 1rem; font-size: .75rem; }
  .section-card { border-radius: var(--radius); }
  .section-card-body { padding: 1rem; }
  .section-card-body-compact { padding: .75rem 1rem; }
}

/* ---- Title help icon ---- */
.title-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: .875rem; height: .875rem; border-radius: 50%;
  background: var(--gray-300); color: #fff;
  font-size: .5625rem; font-weight: 700; cursor: help;
  transition: background .15s;
}
.title-help:hover { background: var(--gray-400); }

/* ---- Lightbox / Image Carousel ---- */
.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 2rem;
}
.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.lightbox-close {
  position: fixed; top: 1rem; right: 1.5rem;
  background: none; border: none; color: #fff;
  font-size: 2rem; cursor: pointer; z-index: 2001;
  opacity: .7; transition: opacity .15s;
  line-height: 1; padding: .5rem;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1); border: none; color: #fff;
  font-size: 2.5rem; cursor: pointer;
  padding: .75rem .5rem; border-radius: 4px;
  z-index: 2001; opacity: .6;
  transition: all .15s; line-height: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,.2); opacity: 1; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-counter {
  position: fixed; bottom: 1.25rem;
  left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7);
  font-size: .875rem; font-weight: 500; z-index: 2001;
}

/* ---- Bucket Browser ---- */
.browser-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem; gap: .75rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-200);
}
.browser-toolbar-actions {
  display: flex; align-items: center; gap: .5rem;
}
.browser-container {
  min-height: 180px;
}
.browser-loading {
  display: flex; align-items: center; justify-content: center;
  gap: .625rem; padding: 3rem 1.5rem;
  color: var(--gray-500); font-size: .875rem;
}
.browser-loading .spinner-icon {
  width: 1.25rem; height: 1.25rem;
  animation: spin .8s linear infinite;
}
.browser-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .75rem; padding: 3rem 1.5rem;
  color: var(--gray-400); font-size: .875rem;
}
.browser-empty svg { opacity: .4; }

/* Breadcrumbs */
.browser-breadcrumbs {
  display: flex; align-items: center; gap: .125rem;
  font-size: .8125rem; flex-wrap: wrap;
}
.browser-breadcrumbs svg {
  width: .875rem; height: .875rem; display: block;
}
.breadcrumb-home {
  color: var(--gray-500); text-decoration: none;
  display: flex; align-items: center; padding: .25rem;
  border-radius: var(--radius-sm); transition: all .15s;
}
.breadcrumb-home:hover { color: var(--primary); background: var(--gray-100); }
.breadcrumb-sep {
  color: var(--gray-300); display: flex; align-items: center;
}
.breadcrumb-link {
  color: var(--primary); text-decoration: none;
  padding: .25rem .375rem; border-radius: var(--radius-sm);
  transition: all .15s; font-weight: 500;
}
.breadcrumb-link:hover { background: var(--primary-light); }
.breadcrumb-active {
  color: var(--gray-700); font-weight: 600;
  padding: .25rem .375rem;
}

/* Page title with icon */
.page-title-with-icon {
  display: inline-flex; align-items: center; gap: .5rem;
}
.page-title-with-icon svg {
  width: 1.375rem; height: 1.375rem;
  color: var(--primary);
}

/* List view: file rows */
.file-name-cell {
  display: flex; align-items: center; gap: .625rem;
}
.file-icon { display: inline-flex; flex-shrink: 0; line-height: 0; }
.file-icon svg { width: 1.25rem; height: 1.25rem; display: block; }
.file-name-link {
  color: var(--gray-900); text-decoration: none;
  font-weight: 500; transition: color .15s;
}
.file-name-link:hover { color: var(--primary); }
.file-name { font-weight: 500; color: var(--gray-900); }
.file-size { font-variant-numeric: tabular-nums; }
.file-date { font-size: .8125rem; }

/* File accent colors */
.file-icon.accent-folder svg { color: #6366F1; }
.file-icon.accent-image svg { color: #10B981; }
.file-icon.accent-video svg { color: #8B5CF6; }
.file-icon.accent-audio svg { color: #F59E0B; }
.file-icon.accent-archive svg { color: #EF4444; }
.file-icon.accent-code svg { color: #06B6D4; }
.file-icon.accent-file svg { color: #94A3B8; }
.file-icon.accent-pdf svg { color: #EF4444; }

/* Grid view */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
  padding: 1rem;
}
.file-card {
  position: relative;
  background: #fff; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 1.25rem .875rem .875rem;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: .5rem;
  cursor: pointer; transition: all .15s ease;
  text-decoration: none; color: inherit;
  overflow: hidden;
}
.file-card:hover {
  border-color: var(--primary); box-shadow: var(--shadow-md);
}
.file-card-icon {
  display: flex; align-items: center; justify-content: center;
  width: 3rem; height: 3rem; border-radius: var(--radius);
  margin-bottom: .25rem;
}
.file-card-icon svg { width: 1.75rem; height: 1.75rem; }

.file-card-icon.accent-folder { background: #EEF2FF; }
.file-card-icon.accent-image { background: #D1FAE5; }
.file-card-icon.accent-video { background: #EDE9FE; }
.file-card-icon.accent-audio { background: #FEF3C7; }
.file-card-icon.accent-archive { background: #FEE2E2; }
.file-card-icon.accent-code { background: #CFFAFE; }
.file-card-icon.accent-file { background: var(--gray-100); }

.file-card-name {
  font-size: .8125rem; font-weight: 600; color: var(--gray-900);
  line-height: 1.3; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 100%;
}
.file-card-meta {
  display: flex; flex-direction: column; align-items: center;
  gap: .125rem; font-size: .6875rem; color: var(--gray-400);
  line-height: 1.3;
}
.file-card-meta .folder-label {
  color: var(--primary); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  font-size: .625rem;
}

.file-card-download, .file-card-delete {
  position: absolute; top: .5rem; padding: .25rem;
  border-radius: var(--radius-sm); transition: all .15s;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; background: #fff;
  border: 1px solid var(--gray-200);
  width: 1.75rem; height: 1.75rem;
}
.file-card-download { right: .5rem; color: var(--primary); }
.file-card-delete { right: 2.5rem; color: var(--danger); cursor: pointer; }
.file-card:hover .file-card-download,
.file-card:hover .file-card-delete { opacity: 1; }
.file-card-download:hover { background: var(--primary-light); }
.file-card-delete:hover { background: #FEE2E2; }
.file-card-download svg, .file-card-delete svg { width: .875rem; height: .875rem; }
.file-card-delete { border: none; }

.file-card-load-more {
  justify-content: center; cursor: pointer;
  border-style: dashed;
}
.file-card-load-more:hover { border-color: var(--primary); }

/* Load more button */
.btn-load-more {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1.25rem; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm); background: #fff;
  cursor: pointer; font-size: .8125rem; color: var(--gray-700);
  font-weight: 500; transition: all .15s;
}
.btn-load-more:hover { background: var(--gray-50); border-color: var(--primary); color: var(--primary); }
.btn-load-more:disabled { opacity: .5; cursor: not-allowed; }
.btn-load-more svg { width: 1rem; height: 1rem; }
.btn-load-more .spinner-icon { animation: spin .8s linear infinite; }

.load-more-row td {
  text-align: center; padding: .75rem;
}

/* Button SVG icons */
.actions .btn-sm svg,
.browser-toolbar-actions .btn-sm svg {
  width: 1rem; height: 1rem; display: block;
}

/* View toggle */
.view-toggle svg {
  width: 1rem; height: 1rem;
}
.view-toggle.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* Responsive grid */
@media (max-width: 640px) {
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: .75rem; gap: .5rem; }
  .file-card { padding: 1rem .625rem .75rem; }
  .file-card-icon { width: 2.5rem; height: 2.5rem; }
  .file-card-icon svg { width: 1.5rem; height: 1.5rem; }
  .file-card-download, .file-card-delete { opacity: 1; }
  .file-card-download { right: .375rem; top: .375rem; }
  .file-card-delete { right: 2.25rem; top: .375rem; }
}
