/*
  Anvil Built Portal - the look.

  Dark theme, brand green (#16a34a), clean, works on a phone. The crew should
  reuse the classes already in here (.card, .btn, .table, .badge, .stat, etc.)
  so every new screen matches without re-inventing styles. The brand colors are
  the CSS variables at the top - use those, do not hard-code new colors.
*/

:root {
  --green:        #16a34a;   /* brand green */
  --green-dark:   #128a3e;
  --green-soft:   rgba(22, 163, 74, 0.15);

  --bg:           #0f1115;   /* page background */
  --panel:        #171a21;   /* cards and bars */
  --panel-2:      #1f2430;   /* table headers, hover */
  --border:       #2a2f3a;

  --text:         #e7ebf0;   /* main text */
  --muted:        #97a0ad;   /* secondary text */

  --danger:       #e5484d;
  --radius:       12px;
  --maxw:         1100px;
}

* { box-sizing: border-box; }

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

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

h1, h2, h3 { line-height: 1.25; }

.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* Top bar and navigation                                              */
/* ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-name { font-size: 18px; letter-spacing: 0.2px; }

.mainnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
}

.navlink {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 15px;
  white-space: nowrap;
}
.navlink:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.navlink.active { background: var(--green-soft); color: var(--green); }

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.who { color: var(--muted); font-size: 14px; }
.signout {
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.signout:hover { background: var(--panel-2); text-decoration: none; }

/* The "Menu" button only shows on small screens. */
.nav-toggle {
  display: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 15px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Page frame                                                          */
/* ------------------------------------------------------------------ */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 60px;
}
.page-plain { display: flex; align-items: center; justify-content: center; min-height: 80vh; }

.page-title { margin: 4px 0 20px; font-size: 26px; }

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

/* ------------------------------------------------------------------ */
/* Cards                                                               */
/* ------------------------------------------------------------------ */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 18px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* ------------------------------------------------------------------ */
/* The four big dashboard numbers                                      */
/* ------------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.stat { display: block; color: var(--text); }
.stat:hover { border-color: var(--green); text-decoration: none; }
.stat-num { font-size: 34px; font-weight: 800; color: var(--green); }
.stat-label { color: var(--muted); margin-top: 4px; font-size: 14px; }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
.table tbody tr:hover { background: var(--panel-2); }

/* ------------------------------------------------------------------ */
/* Lists                                                               */
/* ------------------------------------------------------------------ */

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }

/* ------------------------------------------------------------------ */
/* Badges (status pills)                                               */
/* ------------------------------------------------------------------ */

.badge {
  display: inline-block;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  margin-right: 6px;
}
.badge-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge-danger { background: rgba(229,72,77,0.15); color: var(--danger); border-color: transparent; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-block;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 15px;
  cursor: pointer;
  text-align: center;
}
.btn:hover { border-color: var(--green); text-decoration: none; }
.btn-green { background: var(--green); border-color: var(--green); color: #062a14; font-weight: 700; }
.btn-green:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 14px; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
}
textarea { min-height: 120px; resize: vertical; }

/* ------------------------------------------------------------------ */
/* Login screen                                                        */
/* ------------------------------------------------------------------ */

.loginwrap { width: 100%; max-width: 380px; }
.login-card { text-align: center; }
.login-logo { height: 56px; margin-bottom: 10px; }
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-card form { text-align: left; margin-top: 16px; }
.login-card .btn-block { margin-top: 20px; }

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

.flashes { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.flash-ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.flash-error { background: rgba(229,72,77,0.15); color: var(--danger); border-color: transparent; }

/* ------------------------------------------------------------------ */
/* Small helpers                                                       */
/* ------------------------------------------------------------------ */

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1 1 auto; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------------------ */
/* Phone layout                                                        */
/* ------------------------------------------------------------------ */

@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }

  .nav-toggle { display: block; order: 3; margin-left: auto; }
  .userbox { order: 4; width: 100%; }
  .mainnav {
    order: 5;
    width: 100%;
    flex-direction: column;
    display: none;
  }
  body.nav-open .mainnav { display: flex; }
  .navlink { width: 100%; }
}

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

/* ------------------------------------------------------------------ */
/* AUTH v2 additions: view-as banner, login gateway tabs, code screen  */
/* ------------------------------------------------------------------ */

/* The always-on red banner while the owner is viewing as a client. */
.viewas-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}
.viewas-banner .viewas-exit { margin: 0; }
.viewas-banner .btn-danger {
  background: #fff;
  border-color: #fff;
  color: var(--danger);
}

/* The team-or-client choice on the sign-in page. Visual only: the account's
   role decides where a login really goes. */
.gateway-tabs { margin: 14px 0 6px; }
.gateway-radio { position: absolute; opacity: 0; pointer-events: none; }
.gateway-tab {
  display: inline-block;
  padding: 8px 14px;
  margin: 0 6px 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
}
.gateway-radio-team:checked ~ label[for="who-team"],
.gateway-radio-client:checked ~ label[for="who-client"] {
  border-color: var(--green);
  color: var(--text);
  background: var(--green-soft);
}
.gateway-hint { display: none; margin: 4px 0 0; }
.gateway-radio-team:checked ~ .gateway-hint-team { display: block; }
.gateway-radio-client:checked ~ .gateway-hint-client { display: block; }

/* The "remember this computer" row on the code screen. */
.trust-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  font-weight: normal;
}
.trust-row input[type="checkbox"] { width: auto; margin-top: 4px; }

/* The one-time backup codes list. */
.backup-codes li { font-size: 18px; letter-spacing: 1px; }

/* ------------------------------------------------------------------ */
/* Access checkboxes and folder shares                                 */
/* ------------------------------------------------------------------ */

/* Checkboxes and radios must never stretch to full width the way text
   inputs do. This is the root fix for the misaligned access boxes. */
input[type="checkbox"], input[type="radio"] { width: auto; }

/* A tidy access row: the box on the left, its label right beside it. */
.access-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}
.access-item input[type="checkbox"] {
  width: 18px; height: 18px; margin: 0; flex: none;
}

/* The list of folders shared with a person, and the add-a-share form. */
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.share-row .grow { flex: 1; min-width: 0; }
.share-row .share-name { color: var(--text); font-weight: 600; }
.share-path { color: var(--muted); font-size: 12px; word-break: break-all; }
.share-add { margin-top: 12px; }

/* The file browser: breadcrumbs and the list of folders and files. */
.crumbs { color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
.crumbs a { color: var(--green); text-decoration: none; }
.crumbs .sep { color: var(--muted); margin: 0 4px; }

.filelist { list-style: none; padding: 0; margin: 12px 0; }
.filelist li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px; border-bottom: 1px solid var(--border);
}
.filelist .ficon { flex: none; width: 20px; text-align: center; }
.filelist .fname { flex: 1; min-width: 0; word-break: break-all; }
.filelist .fname a { color: var(--green); text-decoration: none; }
.filelist .fmeta { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* A red safety note (used when a folder path is refused). */
.warn-box {
  background: rgba(229, 72, 77, 0.15);
  border: 1px solid rgba(229, 72, 77, 0.4);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 13px;
}
