/*
 * Heirloom Downloads Portal
 *
 * Colours taken from the EBP application palette:
 *   primary blue   #216ba5    hover  #1d5d90    link  #428bca
 *   accent         #d3d465 / #e1e36d  (the EBP yellow-green)
 *   surfaces       #ffffff / #f0f0f0 / #e6e6e6
 *   borders        #cccccc / #b3b3b3
 *   error          #c5545c    success #27ae60
 *
 * Layout follows mb01: boxes for top-level areas, dense tables below.
 */

:root {
  --primary: #216ba5;
  --primary-dark: #1d5d90;
  --primary-light: #2a87d0;
  --link: #428bca;
  --accent: #d3d465;
  --accent-light: #e1e36d;
  --surface: #ffffff;
  --surface-alt: #f0f0f0;
  --surface-sunk: #e6e6e6;
  --border: #cccccc;
  --border-strong: #b3b3b3;
  --text: #333333;
  --text-muted: #7e898c;
  --error: #c5545c;
  --success: #27ae60;
  --radius: 3px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-alt);
  line-height: 1.5;
}

code, .mono, .size, .keypath {
  font-family: Inconsolata, Consolas, "Courier New", monospace;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ header */

.topbar {
  background: var(--primary);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #fff;
}

.brand-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.who { color: rgba(255, 255, 255, 0.9); }

.who .scope {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  background: var(--accent);
  color: #000;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.topbar-right a, .topbar-right button.linkish {
  color: #fff;
  font-size: 13px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.topbar-right a:hover, .topbar-right button.linkish:hover {
  text-decoration: underline;
}

.topbar-right .sep { color: rgba(255, 255, 255, 0.4); }

/* ------------------------------------------------------------------- shell */

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--primary-dark);
}

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

/* ------------------------------------------------------------- login card */

.centered {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
}

.card-head {
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  border-bottom: 3px solid var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 15px;
  font-weight: 600;
}

.card-body { padding: 20px; }

.card-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ------------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(42, 135, 208, 0.18);
}

.field .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.btn {
  display: inline-block;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary-dark);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--primary-dark); text-decoration: none; }

.btn-full { width: 100%; }

.btn-sm {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover { background: var(--surface-alt); }

.btn-danger {
  background: var(--surface);
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-danger:hover { background: var(--error); color: #fff; }

.inline-form { display: inline; }

/* ---------------------------------------------------------------- messages */

.msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  border-left: 4px solid;
}

.msg-error {
  background: #fdf3f4;
  border-color: var(--error);
  color: #8e3a40;
}

.msg-success {
  background: #f0faf4;
  border-color: var(--success);
  color: #1c7a45;
}

.msg-notice {
  background: #f4faff;
  border-color: var(--primary-light);
  color: var(--primary-dark);
}

.msg-accent {
  background: #fbfce9;
  border-color: var(--accent);
  color: #6b6d20;
}

.credential-box {
  margin-top: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-family: Inconsolata, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  user-select: all;
}

/* -------------------------------------------------- home boxes (mb01 feel) */

.box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.box {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.box:hover {
  text-decoration: none;
  border-top-color: var(--accent);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
  transform: translateY(-1px);
}

.box-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.box-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  min-height: 38px;
}

.box-meta {
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--surface-sunk);
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.box-count {
  font-family: Inconsolata, Consolas, monospace;
  font-weight: 700;
  color: var(--primary);
}

.box-open { color: var(--link); font-weight: 600; }

/* -------------------------------------------------------------- breadcrumb */

.crumbs {
  font-size: 13px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.crumbs a { color: var(--link); }
.crumbs .crumb-sep { color: var(--border-strong); margin: 0 6px; }
.crumbs .crumb-current { font-weight: 600; color: var(--text); }

/* ------------------------------------------------------------------ tables */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  padding: 10px 16px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--surface-sunk);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7fbfe; }

/* Accent left border marks folder rows, echoing mb01's row emphasis. */
tbody tr.row-folder td:first-child {
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}

tbody tr.row-file td:first-child {
  border-left: 3px solid transparent;
  padding-left: 13px;
}

td.col-size, th.col-size {
  text-align: right;
  font-family: Inconsolata, Consolas, monospace;
  color: var(--text-muted);
  white-space: nowrap;
}

td.col-date, th.col-date {
  font-family: Inconsolata, Consolas, monospace;
  color: var(--text-muted);
  white-space: nowrap;
}

td.col-action, th.col-action { text-align: right; white-space: nowrap; }

.entry-name { font-weight: 600; }
.entry-name.folder a { color: var(--primary-dark); }

/* Small type tag before each name. */
.tag {
  display: inline-block;
  min-width: 46px;
  text-align: center;
  padding: 1px 6px;
  margin-right: 10px;
  border-radius: 2px;
  font-family: Inconsolata, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: 1px;
}

.tag-folder { background: var(--accent); color: #000; }
.tag-archive { background: #e8eef4; color: var(--primary-dark); }
.tag-document { background: #eef2f5; color: #4a5c68; }
.tag-data { background: #eef5ee; color: #2c6b3f; }
.tag-script { background: #f5f0e8; color: #7a5c28; }
.tag-checksum { background: #f0f0f0; color: #666; }
.tag-file { background: #f0f0f0; color: #666; }

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* -------------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.tab {
  padding: 8px 20px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: -2px;
}

.tab:hover { text-decoration: none; background: var(--surface-sunk); }

.tab.active {
  background: var(--surface);
  color: var(--primary-dark);
  border-bottom: 2px solid var(--surface);
}

/* ------------------------------------------------------------------- admin */

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
}

.checkgroup {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  max-height: 160px;
  overflow-y: auto;
  background: #fff;
}

.checkgroup label {
  display: block;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  padding: 3px 0;
  cursor: pointer;
}

.checkgroup input { margin-right: 8px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-on { background: #e6f6ec; color: #1c7a45; }
.badge-off { background: #fdf3f4; color: #8e3a40; }
.badge-pending { background: #fbfce9; color: #6b6d20; }
.badge-group { background: #e8eef4; color: var(--primary-dark); margin-right: 4px; }

.scope-cell {
  font-family: Inconsolata, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.rowform { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------------ footer */

.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px 40px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* ------------------------------------------------------------------- error */

.error-code {
  font-family: Inconsolata, Consolas, monospace;
  font-size: 44px;
  font-weight: 700;
  color: var(--border-strong);
  line-height: 1;
  margin-bottom: 8px;
}
