:root {
  /* Best Point brand: purple primary, green accent (from the logo). */
  --bp-navy: #691f74;        /* topbar, active states, admin nav */
  --bp-navy-dark: #521860;
  --bp-accent: #691f74;      /* primary buttons + links */
  --bp-accent-dark: #521860;
  --bp-green: #61a60e;       /* accent echoing the logo wordmark */
  --bp-green-dark: #4e8500;
  --ink: #241a29;
  --muted: #6f6675;
  --line: #e7e2ea;
  --bg: #f6f4f8;
  --card: #ffffff;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(40,16,48,.08), 0 4px 16px rgba(40,16,48,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--bp-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top bar ---- */
.topbar {
  background: var(--bp-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; font-size: 17px; letter-spacing: .2px; }
.topbar .brand img { height: 34px; width: auto; display: block; }
.topbar .brand .wm { font-weight: 700; letter-spacing: .3px; }
.topbar .brand .brand-sep { padding-left: 12px; margin-left: 2px; border-left: 1px solid rgba(255,255,255,.35); font-weight: 400; opacity: .9; }
.topbar .user { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar .user .name { opacity: .85; }
.topbar .user a { color: #fff; opacity: .9; }

/* ---- Layout ---- */
.wrap { max-width: 1100px; margin: 24px auto; padding: 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; }
.card .card-body { padding: 20px; }

/* ---- Breadcrumb / folder chips ---- */
.folder-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.folder-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); color: var(--ink); font-size: 14px; cursor: pointer;
}
.folder-tab.active { background: var(--bp-navy); color: #fff; border-color: var(--bp-navy); }
.folder-tab .ic { opacity: .7; }

.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 6px; opacity: .5; }
.crumbs .here { color: var(--ink); font-weight: 600; }

/* ---- File table ---- */
table.files { width: 100%; border-collapse: collapse; }
table.files th, table.files td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.files th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
table.files tr:last-child td { border-bottom: none; }
table.files td.name { font-weight: 500; }
table.files td.size, table.files td.date { color: var(--muted); white-space: nowrap; }
table.files td.actions { text-align: right; white-space: nowrap; }
.row-icon { display: inline-block; width: 20px; text-align: center; margin-right: 10px; opacity: .8; }
.file-link { background: none; border: none; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
.file-link:hover { color: var(--bp-accent); }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; background: #eef1f5; color: var(--ink);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--bp-accent); color: #fff; }
.btn-primary:hover { background: var(--bp-accent-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-danger { background: #fff; border-color: #e6c3bf; color: var(--danger); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ---- Login ---- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { text-align: center; margin-bottom: 22px; }
.login-card .brand img { width: 230px; max-width: 78%; height: auto; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input[type=text], .field input[type=password], .field input[type=email],
.field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--bp-accent); box-shadow: 0 0 0 3px rgba(105,31,116,.16);
}
.alert { padding: 11px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-ok { background: #e8f5e9; color: #256a34; border: 1px solid #b7dfbd; }
.muted-note { color: var(--muted); font-size: 13px; }

/* Buttons, tabs and nav links never underline on hover (plain text links still do). */
.btn:hover, .folder-tab:hover, .admin-nav a:hover, .topbar a:hover { text-decoration: none; }
.folder-tab:not(.active):hover { border-color: var(--bp-accent); color: var(--bp-accent); }

.page-title { margin: 0 0 14px; font-size: 22px; }
a.file-open { color: var(--ink); }
a.file-open:hover { color: var(--bp-accent); }
.drop-hint { border: 1.5px dashed var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.card.dropping { outline: 3px dashed var(--bp-accent); outline-offset: -6px; background: #faf5fb; }
.card.dropping .drop-hint { border-color: var(--bp-accent); color: var(--bp-accent); }
td.row-actions { text-align: right; white-space: nowrap; }
.who-choice { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; }
.who-choice label { font-weight: 500; cursor: pointer; }
form.is-everyone .member-picks { opacity: .4; pointer-events: none; }

/* ---- Font Awesome icons ---- */
.btn .fa-solid { font-size: .95em; }
.topbar .user a .fa-solid { margin-right: 4px; }
.row-icon .fa-solid { font-size: 17px; }
.ic-folder { color: #e0a526; }
.ic-pdf { color: #d14836; }
.ic-word { color: #2b579a; }
.ic-excel { color: #217346; }
.ic-ppt { color: #d24726; }
.ic-image { color: #7b5ea7; }
.ic-zip { color: #8a6d3b; }
.ic-file { color: var(--muted); }

/* ---- Admin ---- */
.admin-nav { display: flex; gap: 4px; background: var(--bp-navy-dark); padding: 0 20px; }
.admin-nav a { color: #cfd8e3; padding: 14px 16px; font-size: 14px; font-weight: 500; border-bottom: 3px solid transparent; }
.admin-nav a:hover { color: #fff; text-decoration: none; }
.admin-nav a.active { color: #fff; border-bottom-color: var(--bp-green); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-role { background: #eef1f5; color: var(--muted); }
.badge-on { background: #e8f5e9; color: #256a34; }
.badge-off { background: #fdecea; color: var(--danger); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
table.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }

.wrap-wide { max-width: 1400px; }
/* Long values wrap inside their cell instead of pushing the table past the card. */
table.grid td, table.files td.name { overflow-wrap: break-word; }
/* Activity tables: fixed column widths so File gets the leftover room and nothing gets squeezed.
   Below the min-width the card scrolls sideways rather than crushing columns. */
table.grid.log { table-layout: fixed; min-width: 1080px; }
table.grid.log td { overflow-wrap: anywhere; }
table.grid.log th:nth-child(1) { width: 170px; }
table.grid.log th:nth-child(2) { width: 220px; }
table.grid.log th:nth-child(3) { width: 90px; }
table.grid.log th:nth-child(4) { width: 150px; }
table.grid.log th:nth-child(5) { width: 165px; }
table.grid.log th:nth-child(7) { width: 125px; }
table.grid.log-short { min-width: 900px; }
table.grid.log-short th:nth-child(1) { width: 140px; }
table.grid.log-short th:nth-child(3) { width: 165px; }
table.grid.log-short th:nth-child(4) { width: 180px; }
table.grid.log-short th:nth-child(5) { width: auto; }
.card-body { overflow-x: auto; }
.tb-form { display: flex; gap: 8px; align-items: center; }
.tb-form input[type=text], .tb-form select { min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.check-cols { columns: 2; column-gap: 24px; }
.check-cols-3 { columns: 3; column-gap: 20px; }
.btn-row { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-row .spacer { flex: 1; }
.sf-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sf-head > div:first-child { flex: 1; min-width: 200px; }
.sf-create { display: flex; gap: 10px; align-items: flex-end; }

@media (max-width: 860px) {
  .check-cols-3 { columns: 2; }
}

/* ---- Phones ---- */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .wrap { margin: 14px auto; padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }

  .topbar { height: auto; min-height: 56px; padding: 10px 16px; gap: 12px; }
  .topbar .brand { font-size: 16px; min-width: 0; }
  .topbar .user { gap: 12px; flex-shrink: 0; white-space: nowrap; }
  .topbar .user .name { display: none; }

  /* Admin tabs scroll sideways instead of wrapping onto two lines. */
  .admin-nav { overflow-x: auto; white-space: nowrap; padding: 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav a { padding: 13px 12px; flex-shrink: 0; }

  .toolbar h2 { flex: 1 1 100%; }
  .toolbar .spacer { display: none; }
  .tb-form { flex: 1 1 100%; flex-wrap: wrap; }
  .tb-form input[type=text], .tb-form select { flex: 1 1 160px; max-width: none !important; }

  .stats { grid-template-columns: 1fr; gap: 12px; }
  .check-cols, .check-cols-3 { columns: 1; }
  .sf-create { flex-direction: column; align-items: stretch; }
  .btn-row .spacer { display: none; }

  /* Data tables stack into one card per row; each cell shows its column name. */
  table.grid thead, table.files thead { display: none; }
  table.grid, table.grid tbody, table.files, table.files tbody { display: block; width: 100%; }
  table.grid.log { min-width: 0; }
  table.grid tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.grid tr:last-child { border-bottom: none; }
  table.grid td { display: flex; gap: 12px; padding: 3px 0; border: none; text-align: left !important; white-space: normal !important; }
  table.grid td::before { content: attr(data-label); flex: 0 0 84px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding-top: 2px; }
  table.grid td[data-label=""]::before, table.grid td.empty::before { display: none; }
  table.grid td:empty { display: none; }
  table.grid td.empty { display: block; }
  table.grid td:first-child { font-weight: 600; }

  table.files tr { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  table.files tr:last-child { border-bottom: none; }
  table.files td { display: block; padding: 0; border: none; }
  table.files td.name { grid-column: 1 / -1; }
  table.files td.size, table.files td.date { font-size: 13px; padding: 2px 0 0 30px; }
  table.files td.size:empty { display: none; }
  table.files td.date { grid-column: auto; }
  table.files td.size:empty + td.date { grid-column: 1 / -1; }
  table.files td.actions { grid-column: 1 / -1; text-align: left; white-space: normal; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 0 30px; }
  table.files td.actions:empty { display: none; }
}
