@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

:root {
  --bg: #f6f8f3;
  --surface: #ffffff;
  --border: #dfe7d4;
  --text: #0e2410;
  --text-dim: #516159;
  --text-faint: #82927f;
  --accent: #2a7a38;
  --accent-strong: #1f5c2a;
  --accent-contrast: #ffffff;
  --danger: #cc3b3b;
  --tile-projects: #2a7a38;
  --tile-sales: #2f6fed;
  --tile-ppa: #b07507;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(14, 36, 16, 0.08);
  --shadow-lift: 0 8px 24px rgba(14, 36, 16, 0.14);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1f2224;
    --border: #2f3533;
    --text: #e8eee6;
    --text-dim: #a6b3a8;
    --text-faint: #75817a;
    --accent: #4caf5e;
    --accent-strong: #6cc47b;
    --accent-contrast: #0e2410;
    --shadow: none;
    --shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
  .logo-light { display: none !important; }
}
@media (prefers-color-scheme: light) { .logo-dark { display: none !important; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Poppins", system-ui, sans-serif; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 500; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.link { border: 0; background: none; color: var(--text-dim); padding: 6px 8px; white-space: nowrap; }
.btn.link:hover { color: var(--text); }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.top img.logo { height: 30px; display: block; }
.who { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--border); display: grid; place-items: center; font-weight: 600; color: var(--text-dim); flex: none; }

main.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 600; margin: 0; }
.sub { color: var(--text-dim); margin: 0 0 24px; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 22px; min-height: 150px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--tile-color, var(--accent)); }
.tile .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--tile-color, var(--accent)); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 18px; margin-bottom: 8px; }
.tile .name { font-size: 18px; font-weight: 600; }
.tile .desc { color: var(--text-dim); font-size: 14px; flex: 1; }
.tile[data-app="projects"] { --tile-color: var(--tile-projects); }
.tile[data-app="sales"] { --tile-color: var(--tile-sales); }
.tile[data-app="ppa"] { --tile-color: var(--tile-ppa); }

.role { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-strong); text-transform: capitalize; }
.role.viewer { background: color-mix(in srgb, var(--text-faint) 20%, transparent); color: var(--text-dim); }
.role.owner { background: color-mix(in srgb, var(--tile-ppa) 18%, transparent); color: var(--tile-ppa); }
.role.off { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.empty { padding: 32px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-dim); text-align: center; }

/* Members */
.members { margin-top: 48px; }
.members-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.members-head input[type=search] { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 220px; }
.table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 2fr) repeat(var(--apps, 3), minmax(90px, 1fr)); align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row.head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); background: color-mix(in srgb, var(--bg) 60%, var(--surface)); }
button.row { width: 100%; text-align: left; border: 0; border-top: 1px solid var(--border); background: none; cursor: pointer; }
button.row:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.row.inactive { opacity: .55; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .text { min-width: 0; }
.person .nm, .person .em { display: block; }
.person .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .em { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash { color: var(--text-faint); }

/* Member dialog */
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lift); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { padding: 24px; display: grid; gap: 16px; }
label.field { display: grid; gap: 4px; font-size: 14px; color: var(--text-dim); }
label.field input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0; display: grid; gap: 10px; }
legend { padding: 0 6px; font-size: 14px; color: var(--text-dim); }
.app-access { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-access select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.actions .right { display: flex; gap: 8px; margin-left: auto; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 0; }
.hint { color: var(--text-faint); font-size: 13px; margin: 0; }

/* Login and plain pages */
body.plain { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.plain-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px 32px; text-align: center; box-shadow: var(--shadow-lift); }
.plain-logo { height: 36px; margin-bottom: 20px; }
#gsi { display: flex; justify-content: center; margin: 20px 0 8px; min-height: 44px; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  .who .email { display: none; }
  main.wrap { padding: 24px 16px 48px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .row.head { display: none; }
  .row .cell::before { content: attr(data-app) ": "; color: var(--text-faint); font-size: 13px; }
}
