:root {
  --bg-page: #f6f8fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #1e2a3b;
  --muted: #66758c;
  --heading: #0f1f38;

  --accent: #2554c7;
  --accent-hover: #1c418f;
  --accent-soft: rgba(37, 84, 199, 0.10);

  --success: #17804f;
  --success-bg: rgba(23, 128, 79, 0.10);
  --error: #c62828;
  --error-bg: rgba(198, 40, 40, 0.09);
  --pending: #b06a00;
  --pending-bg: rgba(176, 106, 0, 0.10);

  --sidebar-bg: #0d1b33;
  --sidebar-bg-2: #142a4c;
  --sidebar-text: rgba(255, 255, 255, 0.82);
  --sidebar-text-dim: rgba(255, 255, 255, 0.52);

  --shadow-sm: 0 1px 2px rgba(15, 31, 56, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 31, 56, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-size: 15px;
}

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

h1 {
  font-size: 1.35em;
  font-weight: 700;
  color: var(--heading);
  margin: 0 0 4px;
}

.muted { color: var(--muted); }
.muted.small { font-size: 0.85em; margin-top: 16px; }

/* ---------- app shell (authenticated pages) ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.72em;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-word {
  font-weight: 700;
  font-size: 1.08em;
  color: #fff;
  letter-spacing: 0.01em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  flex: 1;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 0.92em;
  font-weight: 500;
}

.side-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.side-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon { width: 18px; text-align: center; font-size: 0.95em; }

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  margin-top: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78em;
  flex-shrink: 0;
}

.side-user-info { overflow: hidden; }

.side-user-name {
  font-size: 0.87em;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-user-role {
  font-size: 0.75em;
  color: var(--sidebar-text-dim);
}

.logout-link {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding: 9px;
  border-radius: 8px;
  font-size: 0.85em;
  color: var(--sidebar-text-dim);
}
.logout-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.main-col { flex: 1; min-width: 0; }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px 36px 64px;
}

/* ---------- auth shell (login / activate / verify) ---------- */

.auth-body { background: var(--bg-page); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
}

.brand-auth { display: flex; align-items: center; gap: 10px; }
.brand-auth .brand-word { color: var(--heading); }

.auth-container { width: 100%; max-width: 420px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}

.card.narrow { max-width: 420px; }

form label {
  display: block;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"],
input[type="date"],
input[type="file"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 1em;
  margin-bottom: 14px;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button, .link-button, .button-link {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 7px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95em;
  font-family: inherit;
}

button:hover, .button-link:hover { background: var(--accent-hover); color: #fff; }

.link-button {
  background: none;
  color: var(--error);
  padding: 0;
  font-weight: 500;
  text-decoration: underline;
}
.link-button:hover { color: #8f1d1d; background: none; }

.button-link { display: inline-block; text-decoration: none; }

.upload-form { display: flex; gap: 12px; align-items: center; }
.upload-form input[type="file"] { margin-bottom: 0; flex: 1; }

.flashes { margin-bottom: 18px; }
.flash {
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.92em;
}
.flash-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(198, 40, 40, 0.25); }
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(23, 128, 79, 0.25); }

.qr {
  display: block;
  margin: 16px auto;
  width: 220px;
  height: 220px;
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.secret {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 5px;
  word-break: break-all;
  color: var(--text);
}

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

.files-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.files-table th, .files-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92em;
}

.files-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-page);
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.files-table tbody tr:last-child td { border-bottom: none; }
.files-table tbody tr:hover { background: rgba(37, 84, 199, 0.03); }

.actions { display: flex; gap: 14px; align-items: center; }
.actions form { margin: 0; }

.tag {
  font-size: 0.68em;
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

details { margin: 8px 0 16px; color: var(--muted); font-size: 0.9em; }
details summary { cursor: pointer; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.pill-approved { background: var(--success-bg); color: var(--success); }
.pill-rejected { background: var(--error-bg); color: var(--error); }
.pill-pending  { background: var(--pending-bg); color: var(--pending); }

.tag-type {
  background: var(--bg-page);
  color: var(--heading);
  border: 1px solid var(--border);
  font-weight: 700;
}

.approved-by { font-size: 0.85em; }
.approved-by div { margin-bottom: 2px; }

.inline-form {
  display: inline-block;
  margin: 0 6px 0 0 !important;
}
