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

:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --text: #1c2733;
  --muted: #647586;
  --line: #d9e1e8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #e6f5f2;
  --ink: #203044;
  --danger-bg: #fff1f1;
  --danger: #b42318;
  --success-bg: #ebf8ef;
  --success: #087443;
  --shadow: 0 18px 45px rgba(28, 39, 51, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.12), rgba(15, 118, 110, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: 'Source Sans 3', Arial, sans-serif;
  font-size: 15px;
}

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(28, 39, 51, 0.12);
  padding: 40px 36px 36px;
  display: grid;
  gap: 18px;
}

.login-logo {
  display: block;
  max-height: 68px;
  width: auto;
  object-fit: contain;
}

.login-info { display: grid; gap: 4px; }

.login-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
  color: var(--ink);
}

.login-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form { display: grid; gap: 14px; }
.login-form button { width: 100%; font-size: 15px; }

/* ── Shell ── */
.shell {
  width: min(1200px, calc(100% - 32px));
  margin: 28px auto 48px;
  display: grid;
  gap: 18px;
}

/* ── Hero ── */
.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 18px 26px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff 0%, #f1f8f6 100%);
  box-shadow: var(--shadow);
}

.brand-logo {
  display: block;
  max-height: 52px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.hero-text { min-width: 0; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

h1, h2, .subtitle { margin: 0; }

h1 {
  font-size: 26px;
  line-height: 1.2;
  color: var(--ink);
  font-family: 'Lexend', Arial, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-family: 'Lexend', Arial, sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.3;
  color: var(--ink);
}

.subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.hero-meta {
  display: grid;
  gap: 8px;
  justify-items: end;
  flex-shrink: 0;
}

.hero-meta > span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.logout-btn {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Workspace grid ── */
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(400px, 1.6fr);
  gap: 18px;
  align-items: start;
}

/* ── Panel ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 4px 16px rgba(28, 39, 51, 0.05);
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.section-title h2 {
  margin-bottom: 3px;
}

.section-title > div > span,
.section-title > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.result-count {
  white-space: nowrap;
  padding-top: 2px;
}

/* ── Forms ── */
.upload-form,
.filter-form {
  display: grid;
  gap: 12px;
}

.filter-form {
  grid-template-columns: 1fr 1fr;
  align-items: end;
}

/* Name spans full width */
.filter-form .filter-name { grid-column: 1 / -1; }

/* Date range spans full width */
.date-range-label { grid-column: 1 / -1; }

/* Actions right-aligned, full width */
.filter-form .filter-actions { grid-column: 1 / -1; justify-content: flex-end; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-family: 'Source Sans 3', Arial, sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
  background: #fff;
}

input[type="password"],
input[type="search"],
select {
  padding: 0 12px;
}

/* ── Drop zone ── */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 160px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: #fafbfc;
  cursor: pointer;
  padding: 28px 20px;
  text-align: center;
  transition: border-color 0.18s, background 0.18s;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone.dragover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}

.drop-zone.has-files {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}

.drop-icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.drop-zone:hover .drop-icon,
.drop-zone.has-files .drop-icon {
  opacity: 1;
  transform: translateY(-2px);
}

.drop-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
  max-width: 100%;
}

.drop-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.drop-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  font-size: 11px;
  color: var(--text);
}

/* upload button disabled state */
#upload-btn:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}
#upload-btn:disabled:hover {
  background: var(--line);
}

button,
.filter-actions a {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 16px;
  font: inherit;
  font-family: 'Lexend', Arial, sans-serif;
  font-size: 14px;
  font-weight: 800;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover { background: var(--accent-dark); }

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.filter-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.filter-actions a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Date range wrap ── */
.date-range-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.date-range-wrap input[type="text"] {
  padding-right: 34px;
  cursor: pointer;
}

.date-clear {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  min-height: unset;
  width: 36px;
  padding: 0;
  border-radius: 0 6px 6px 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s;
}

.date-clear:hover {
  background: transparent;
  color: var(--danger);
}

/* ── Flatpickr overrides ── */
.flatpickr-calendar {
  font-family: 'Lexend', Arial, sans-serif !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 12px 40px rgba(28, 39, 51, 0.14) !important;
  border: 1px solid var(--line) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}

.flatpickr-day.inRange {
  background: var(--accent-soft) !important;
  border-color: var(--accent-soft) !important;
  box-shadow: -5px 0 0 var(--accent-soft), 5px 0 0 var(--accent-soft) !important;
  color: var(--accent-dark) !important;
}

.flatpickr-day:hover {
  background: var(--accent-soft) !important;
  border-color: transparent !important;
}

.flatpickr-months .flatpickr-month,
.flatpickr-weekdays,
span.flatpickr-weekday {
  background: var(--accent) !important;
  color: #fff !important;
  fill: #fff !important;
}

.flatpickr-current-month input.cur-year,
.flatpickr-current-month .flatpickr-monthDropdown-months {
  color: #fff !important;
}

.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg {
  fill: rgba(255,255,255,0.7) !important;
}

/* ── Messages ── */
.messages { display: grid; gap: 8px; }

.message {
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  border-left: 3px solid transparent;
}

.message.success {
  background: var(--success-bg);
  color: var(--success);
  border-left-color: var(--success);
}

.message.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-left-color: var(--danger);
}

/* ── File list ── */
.files-panel { padding-bottom: 8px; }

.table-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.file-list { display: grid; }

.file-row {
  display: grid;
  grid-template-columns: 56px minmax(200px, 1fr) minmax(130px, 190px) auto;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  padding: 10px 4px;
  border-radius: 6px;
  transition: background 0.1s;
}

.file-row:last-child { border-bottom: none; }
.file-row:hover { background: rgba(15, 118, 110, 0.03); }

.file-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.file-icon.ext-pdf   { background: #fff0ee; color: #c0392b; }
.file-icon.ext-xlsx,
.file-icon.ext-xls   { background: #edfaf0; color: #1a7f47; }
.file-icon.ext-docx,
.file-icon.ext-doc   { background: #eaf2ff; color: #1d4ed8; }
.file-icon.ext-pptx,
.file-icon.ext-ppt   { background: #fff4ec; color: #c05621; }
.file-icon.ext-zip,
.file-icon.ext-rar   { background: #f5f0ff; color: #6d28d9; }
.file-icon.ext-png,
.file-icon.ext-jpg,
.file-icon.ext-jpeg,
.file-icon.ext-webp  { background: #fefce8; color: #92400e; }

.file-main, .file-detail { display: grid; gap: 3px; }

/* ── Department badge ── */
.dept-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Lexend', Arial, sans-serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.dept-badge.dept-1 { background: #e6f5f2; color: #0b5f59; }
.dept-badge.dept-2 { background: #eaf2ff; color: #1d4ed8; }
.dept-badge.dept-3 { background: #fff7e6; color: #92400e; }

.file-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.file-main strong {
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

.file-path,
.file-ip-inline,
.file-detail span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.file-detail { justify-items: end; text-align: right; }

/* thumbnail inside icon box */
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}

/* action button */
.file-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.btn-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 56px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Lexend', Arial, sans-serif;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  padding: 0 12px;
}
.btn-open:hover { background: var(--accent-dark); }

.btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 56px;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  font-family: 'Lexend', Arial, sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0 12px;
}
.btn-delete:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-delete:disabled { opacity: 0.5; cursor: not-allowed; }

.file-actions { gap: 6px; flex-direction: column; }

.empty {
  margin: 0;
  color: var(--muted);
  padding: 8px 0;
  font-size: 13px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 4px 8px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Lexend', Arial, sans-serif;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.page-btn:hover:not(.disabled):not(.active) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

.page-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 34px;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

/* ── Responsive ── */
@media (max-width: 1020px) {
  .workspace { grid-template-columns: 1fr; }
  /* filter-form stays 2fr 1fr — works fine in full width */
  .filter-actions { align-items: stretch; }
}

@media (max-width: 700px) {
  .shell {
    width: calc(100% - 20px);
    margin: 10px auto 24px;
  }

  .hero {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    padding: 14px 16px;
    gap: 10px;
  }

  .brand-logo { max-height: 40px; }

  .hero-meta {
    grid-column: 1 / -1;
    justify-items: start;
    flex-direction: row;
    display: flex;
    gap: 8px;
  }

  h1 { font-size: 20px; }

  .panel { padding: 16px; }

  .filter-form { grid-template-columns: 1fr; }
  .filter-form label,
  .filter-form .filter-name,
  .date-range-label,
  .filter-form .filter-actions { grid-column: 1; }
  .filter-form .filter-actions { justify-content: stretch; }

  .filter-actions { flex-direction: column; }
  .filter-actions button,
  .filter-actions a,
  .upload-form button { width: 100%; }

  .file-row {
    grid-template-columns: 48px 1fr auto;
    align-items: start;
  }

  .file-detail {
    grid-column: 2;
    justify-items: start;
    text-align: left;
  }

  .file-actions { grid-column: 3; grid-row: 1 / 3; justify-content: center; }

  .login-card { padding: 28px 18px 24px; }
}
