:root {
  --ink: #242724;
  --ink-soft: #626760;
  --charcoal: #2d312e;
  --charcoal-2: #373c38;
  --cream: #f4f0e6;
  --cream-deep: #e9e2d2;
  --paper: #fffdf8;
  --green: #93d5a0;
  --green-deep: #347348;
  --green-wash: #e5f5e8;
  --line: #d8d4c9;
  --danger: #a8403a;
  --danger-wash: #fae9e6;
  --warning: #8a6719;
  --warning-wash: #fff3cf;
  --shadow: 0 18px 50px rgba(34, 39, 35, .09);
  --radius: 18px;
  --sidebar: 252px;
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
}

body { margin: 0; min-height: 100vh; background: var(--cream); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .86em; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar);
  padding: 28px 20px 22px;
  display: flex;
  flex-direction: column;
  color: #f9f7f0;
  background:
    radial-gradient(circle at 12% 2%, rgba(147, 213, 160, .16), transparent 30%),
    var(--charcoal);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  color: var(--charcoal);
  background: var(--green);
  font-weight: 850;
  font-size: 1.2rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.28);
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -.02em; font-size: 1.08rem; }
.brand small { margin-top: 2px; color: #afb6ae; font-size: .75rem; }
.brand.large .brand-mark { width: 52px; height: 52px; font-size: 1.4rem; }
.brand.large strong { font-size: 1.3rem; }

.nav { display: grid; gap: 7px; margin-top: 48px; }
.nav a {
  padding: 12px 14px;
  border-radius: 11px;
  color: #cbd0ca;
  text-decoration: none;
  font-size: .93rem;
  font-weight: 650;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav a:hover { color: white; background: rgba(255,255,255,.06); transform: translateX(2px); }
.nav a.active { color: #172219; background: var(--green); }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 13px;
  background: rgba(255,255,255,.035);
}
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: .76rem; }
.sidebar-foot small { margin-top: 3px; color: #aeb5ad; font-size: .7rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(147,213,160,.12); }

.main-wrap { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  min-height: 104px;
  padding: 24px clamp(22px, 4vw, 58px);
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid rgba(76, 82, 76, .12);
}
.topbar > div { flex: 1; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.45rem, 2.5vw, 2rem); letter-spacing: -.045em; }
.eyebrow {
  display: block;
  color: var(--green-deep);
  font-size: .7rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.content { padding: 32px clamp(22px, 4vw, 58px) 64px; }

.button {
  min-height: 42px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  text-decoration: none;
  font-weight: 750;
  font-size: .86rem;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(52,115,72,.25); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.primary { color: #152319; background: var(--green); border-color: #80c58e; box-shadow: 0 8px 22px rgba(62,126,80,.16); }
.button.primary:hover { background: #a4e0af; }
.button.secondary { color: var(--ink); background: var(--cream); border-color: var(--line); }
.button.ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.button.danger-quiet { color: var(--danger); background: var(--danger-wash); border-color: #efc6c1; }
.button.small { min-height: 34px; padding: 7px 11px; font-size: .76rem; border-radius: 9px; }
.button.full { width: 100%; }
.auth-link { display: block; text-align: center; }
.button.loading { opacity: .75; cursor: wait; }
.icon-button { border: 0; background: transparent; cursor: pointer; }
.menu-button { display: none; font-size: 1.35rem; }

.flash-region { position: relative; z-index: 4; display: grid; gap: 10px; margin-bottom: 18px; }
.flash {
  min-height: 52px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(34,39,35,.06);
}
.flash.success { border-color: #b9dfc0; background: var(--green-wash); }
.flash.error { border-color: #e9bbb7; background: var(--danger-wash); }
.flash.warning { border-color: #ead694; background: var(--warning-wash); }
.flash.info { border-color: #c7d4cf; }
.flash-icon { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--ink-soft); }
.flash.success .flash-icon { background: var(--green-deep); }
.flash.error .flash-icon { background: var(--danger); }
.flash.warning .flash-icon { background: var(--warning); }
.flash button { margin-left: auto; border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; }

.hero {
  min-height: 210px;
  padding: clamp(28px, 5vw, 52px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  position: relative;
  border-radius: 24px;
  color: #f7f5ee;
  background:
    radial-gradient(circle at 86% 8%, rgba(147,213,160,.32), transparent 27%),
    linear-gradient(125deg, #252925, #363c37);
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; width: 180px; height: 180px; right: -54px; bottom: -90px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; }
.hero h2 { max-width: 680px; margin: 9px 0 7px; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1; letter-spacing: -.06em; }
.hero p { max-width: 620px; margin: 0; color: #c2c9c2; }
.hero .eyebrow { color: var(--green); }
.hero .button { position: relative; z-index: 1; flex: 0 0 auto; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0; }
.stat-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 7px 24px rgba(34,39,35,.04); }
.stat-card.accent { background: var(--green-wash); border-color: #c6e3cb; }
.stat-card span, .stat-card small { display: block; color: var(--ink-soft); }
.stat-card span { font-size: .78rem; font-weight: 750; }
.stat-card strong { display: block; margin: 12px 0 5px; font-size: 2.15rem; letter-spacing: -.06em; }
.stat-card small { font-size: .72rem; }

.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,253,248,.88); box-shadow: 0 9px 32px rgba(34,39,35,.045); }
.panel-heading { min-height: 48px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 1.22rem; letter-spacing: -.03em; }
.text-link { color: var(--green-deep); font-size: .8rem; font-weight: 750; text-decoration: none; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 350px); align-items: start; gap: 20px; }
.structure-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 18px; }
.count { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--green-deep); background: var(--green-wash); font-weight: 850; font-size: .76rem; }
.compact-list { display: grid; max-height: 300px; overflow: auto; }
.compact-list > div { min-height: 58px; padding: 9px 2px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #e6e2d9; }
.compact-list > div > span:nth-child(2) { flex: 1; }
.compact-list strong, .compact-list small { display: block; }
.compact-list strong { font-size: .8rem; }
.compact-list small { margin-top: 3px; color: var(--ink-soft); font-size: .66rem; }
.compact-list .app-icon { width: 34px; height: 34px; }
.inset-form { margin: 18px -6px -6px; padding: 16px; border-radius: 13px; background: #f1eee6; }
.form-panel { position: sticky; top: 20px; }

.table-wrap { overflow-x: auto; margin: 0 -8px -8px; }
.table-search {
  margin: -5px 0 16px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}
.table-search label { width: min(100%, 360px); display: grid; gap: 7px; }
.table-search label > span { font-size: .76rem; font-weight: 750; }
.table-search input { min-height: 40px; }
.table-search-count { padding-bottom: 11px; color: var(--ink-soft); font-size: .7rem; white-space: nowrap; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid #e4e0d7; vertical-align: middle; }
th { color: var(--ink-soft); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .84rem; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--ink-soft); font-size: .71rem; }
td.actions, th.actions { text-align: right; }
td.actions form { display: inline-flex; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(147,213,160,.06); }

.badge, .role-chip, .inline-label { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 750; }
.badge { padding: 5px 9px; font-size: .68rem; }
.badge.success { color: #275d38; background: var(--green-wash); }
.badge.muted { color: #656964; background: #ebe9e3; }
.badge.warning { color: #6d5114; background: var(--warning-wash); }
.badge.danger { color: #85332e; background: var(--danger-wash); }
.role-chip { padding: 6px 10px; color: #36523d; background: #edf2e9; font-size: .72rem; }
.inline-label { margin-left: 7px; padding: 3px 6px; color: var(--green-deep); background: var(--green-wash); font-size: .58rem; }

.stack-form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: .76rem; font-weight: 750; }
.field small, .form-note { color: var(--ink-soft); font-size: .69rem; line-height: 1.5; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cfcbbf;
  border-radius: 10px;
  color: var(--ink);
  background: #fffefb;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #a8afa7; }
input:disabled { color: #696d68; background: #efede7; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 9px; font-size: .78rem; font-weight: 650; }
.check input { width: 17px; min-height: 17px; accent-color: var(--green-deep); }
.search { display: flex; gap: 8px; }
.search input { min-width: 180px; }
.directory-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin: -5px 0 22px;
  padding: 16px;
  border-radius: 13px;
  background: #f1eee6;
}
.filter-actions { display: flex; gap: 8px; }
td.actions { white-space: nowrap; }

@media (max-width: 1000px) {
  .directory-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .directory-filters { grid-template-columns: 1fr; }
  .filter-actions .button { flex: 1; }
}

.application-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.application-card { padding: 18px; border: 1px solid #dedacf; border-radius: 15px; background: #fffefb; }
.application-head { display: flex; align-items: center; gap: 11px; }
.application-head > div { flex: 1; min-width: 0; }
.application-head h3 { margin: 0 0 4px; font-size: .95rem; }
.application-head code { color: var(--ink-soft); }
.app-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #294632; background: var(--green-wash); font-weight: 850; }
.application-card > p { min-height: 38px; color: var(--ink-soft); font-size: .77rem; line-height: 1.5; }
.meta-row { display: flex; gap: 14px; padding-top: 11px; border-top: 1px solid #e8e4dc; color: var(--ink-soft); font-size: .68rem; }
.directory-export { margin-top: 12px; padding: 11px; display: flex; align-items: center; gap: 12px; border: 1px solid #c6e3cb; border-radius: 11px; background: var(--green-wash); }
.directory-export > span { flex: 1; min-width: 0; }
.directory-export strong, .directory-export small { display: block; }
.directory-export strong { color: var(--green-deep); font-size: .73rem; }
.directory-export small { margin-top: 3px; color: var(--ink-soft); font-size: .65rem; line-height: 1.4; }
.directory-export form { flex: 0 0 auto; }
.credential-list { margin-top: 11px; display: grid; gap: 6px; }
.credential-list > div { padding: 8px 9px; display: flex; align-items: center; gap: 8px; border-radius: 9px; background: #f2f0e9; }
.credential-list > div > span:first-child { flex: 1; min-width: 0; }
.credential-list strong, .credential-list code { display: block; }
.credential-list strong { font-size: .7rem; }
.credential-list code { margin-top: 2px; overflow: hidden; color: var(--ink-soft); font-size: .61rem; text-overflow: ellipsis; }
.card-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.credential-form { display: flex; flex: 1; gap: 7px; }
.credential-form input { min-width: 110px; min-height: 34px; padding: 7px 9px; font-size: .75rem; }

.secret-reveal { margin-bottom: 20px; padding: 22px; border: 1px solid #d8c276; border-radius: var(--radius); background: var(--warning-wash); }
.secret-reveal h2 { margin: 5px 0; }
.secret-reveal p { margin: 0; color: #665526; }
.secret-value { margin-top: 14px; padding: 10px; display: flex; align-items: center; gap: 10px; border: 1px dashed #b89d4d; border-radius: 10px; background: #fffaf0; }
.secret-value code { flex: 1; overflow-wrap: anywhere; }

.activity-list { display: grid; }
.activity-row { padding: 13px 4px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #e4e0d7; }
.activity-row:last-child { border-bottom: 0; }
.activity-row > div { flex: 1; }
.activity-row strong, .activity-row small { display: block; }
.activity-row strong { font-size: .8rem; }
.activity-row small { margin-top: 3px; color: var(--ink-soft); font-size: .68rem; }
.activity-row code { color: var(--ink-soft); font-size: .66rem; }
.event-mark { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-soft); }
.event-mark.success { background: var(--green-deep); }
.event-mark.failure { background: var(--danger); }
.event-mark.blocked { background: var(--warning); }
.empty-state { padding: 45px 20px; color: var(--ink-soft); text-align: center; font-size: .84rem; }

.guest-wrap, .guest-content { min-height: 100vh; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-story {
  padding: clamp(32px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f7f5ef;
  background:
    radial-gradient(circle at 8% 92%, rgba(147,213,160,.25), transparent 34%),
    linear-gradient(145deg, #242824, #353a36);
}
.login-story h1 { max-width: 720px; margin: 14px 0; font-size: clamp(2.8rem, 6vw, 6.5rem); line-height: .91; letter-spacing: -.075em; }
.login-story p { max-width: 590px; color: #c6ccc5; font-size: clamp(1rem, 1.7vw, 1.25rem); line-height: 1.6; }
.login-story .eyebrow { color: var(--green); }
.trust-line { display: flex; align-items: center; gap: 11px; color: #cbd0ca; font-size: .78rem; }
.login-panel { padding: 32px; display: grid; place-items: center; }
.auth-card { width: min(100%, 430px); padding: clamp(28px, 5vw, 46px); }
.card-heading { margin-bottom: 24px; }
.card-heading h2 { margin: 8px 0; font-size: 1.75rem; letter-spacing: -.045em; }
.card-heading p { margin: 0; color: var(--ink-soft); }
.form-note { margin: 2px 0 0; text-align: center; }
.error-page { min-height: 70vh; display: grid; place-content: center; justify-items: start; }
.error-page h1 { margin: 10px 0; font-size: clamp(2rem, 6vw, 4.5rem); letter-spacing: -.06em; }
.error-page p { max-width: 580px; margin: 0 0 24px; color: var(--ink-soft); line-height: 1.6; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .application-grid { grid-template-columns: 1fr; }
  .structure-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 850px) {
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .menu-button { display: inline-grid; place-items: center; }
  .split-layout { grid-template-columns: 1fr; }
  .structure-grid { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .login-layout { grid-template-columns: 1fr; }
  .login-story { min-height: 360px; gap: 50px; }
  .login-story h1 { font-size: clamp(2.7rem, 12vw, 5rem); }
  .login-panel { padding: 28px 18px 50px; }
}

@media (max-width: 600px) {
  .topbar { min-height: 88px; padding: 17px 16px; }
  .topbar .button.ghost { padding: 8px 10px; }
  .content { padding: 20px 14px 48px; }
  .hero { min-height: 260px; padding: 28px 22px; align-items: flex-start; flex-direction: column; }
  .hero .button { width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 17px; }
  .stat-card strong { font-size: 1.75rem; }
  .panel { padding: 18px 14px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .search { width: 100%; }
  .search input { min-width: 0; }
  .login-story { min-height: 430px; padding: 28px 22px; }
  .activity-row code { display: none; }
  .credential-form { flex-basis: 100%; }
  .table-search { align-items: stretch; flex-direction: column; gap: 5px; }
  .table-search label { width: 100%; }
  .table-search-count { padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
.centered-auth { min-height: 100vh; padding: 28px; display: grid; place-items: center; }
.centered-auth .auth-card { width: min(100%, 470px); }
.account-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 70px; }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.account-actions { display: flex; align-items: center; gap: 10px; }
.account-actions form { margin: 0; }
.account-intro { padding: 64px 0 28px; }
.account-intro h1 { margin: 8px 0; font-size: clamp(2.1rem, 5vw, 4.2rem); letter-spacing: -.06em; }
.account-intro p { margin: 0; color: var(--ink-soft); }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.account-access { margin-top: 20px; }
.edit-layout { width: min(720px, 100%); margin: 0 auto; }
.edit-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }

@media (max-width: 720px) {
  .account-shell { width: min(100% - 28px, 1180px); padding-top: 18px; }
  .account-head { flex-direction: column; align-items: stretch; }
  .account-actions { align-items: stretch; }
  .account-actions .button, .account-actions form, .account-actions form .button { flex: 1; width: 100%; }
  .account-intro { padding-top: 42px; }
  .account-grid { grid-template-columns: 1fr; }
}
