/* BYNFLOW — palette: orange #FF6700, light grey #EBEBEB, grey #C0C0C0, blue #3A6EA5, navy #004E98 */

:root {
  --orange: #FF6700;
  --orange-dark: #e35c00;
  --light-grey: #EBEBEB;
  --grey: #C0C0C0;
  --blue: #3A6EA5;
  --navy: #004E98;
  --white: #FFFFFF;
  --text: #1F2430;
  --text-muted: #6B7280;
  --danger: #D64545;
  --success: #2E8B57;
  --warning: #C77700;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 20, 45, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  background: var(--light-grey);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}

a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { font-weight: 700; margin: 0 0 12px; }
p { line-height: 1.5; }

/* ---------------------------------------------------------------- */
/* Login / installer shared card                                     */
/* ---------------------------------------------------------------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--light-grey) 0%, #dfe3e8 100%);
}

.login-wrap { width: 100%; max-width: 920px; padding: 24px; }

.login-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 480px;
}

.login-card.single { grid-template-columns: 1fr; max-width: 460px; margin: 0 auto; }

.login-left {
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-left h1 { font-size: 28px; margin-bottom: 24px; }

.login-right {
  background: linear-gradient(150deg, var(--navy) 0%, var(--blue) 70%, var(--orange) 160%);
  color: var(--white);
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-right h2 { font-size: 26px; margin-bottom: 12px; }
.login-right p { opacity: 0.9; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 6px;
}

.field-input,
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--grey);
  background: var(--light-grey);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  user-select: text;
}

.field-input:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--orange);
  background: var(--white);
}

label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; color: var(--text-muted); }
label input, label select { margin-top: 6px; font-weight: 400; color: var(--text); }
label[for] { display: block; }

.btn {
  display: inline-block;
  background: var(--orange);
  color: var(--white);
  border: none;
  padding: 13px 24px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--orange-dark); }
.btn:active { transform: scale(0.98); }
.btn:disabled { background: var(--grey); cursor: not-allowed; }

.btn-block { display: block; width: 100%; margin-top: 24px; text-align: center; }

.btn-secondary { background: var(--white); color: var(--navy); border: 1px solid var(--grey); }
.btn-secondary:hover { background: var(--light-grey); }

.btn-small { padding: 7px 14px; font-size: 12px; border-radius: 8px; }

.btn-link {
  display: inline-block;
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--blue);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { color: var(--navy); text-decoration: underline; }

.inline-form { display: inline-block; }
.inline-label { font-weight: 600; font-size: 13px; color: var(--text-muted); }
.inline-label select { display: inline-block; width: auto; margin-left: 8px; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  font-weight: 500;
}
.alert-error { background: #FDECEC; color: var(--danger); border: 1px solid #F5C2C2; }
.alert-success { background: #E9F7EF; color: var(--success); border: 1px solid #BFE5CE; }

.install-notice {
  background: #FFF3E9;
  border: 1px solid #FFD3AD;
  border-radius: 10px;
  padding: 16px;
  margin: 16px 0;
}
.install-notice code {
  background: var(--white);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 15px;
  letter-spacing: 1px;
}

/* ---------------------------------------------------------------- */
/* Installer wizard                                                  */
/* ---------------------------------------------------------------- */
.install-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.install-wrap { width: 100%; max-width: 640px; }
.install-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 44px;
}
.install-brand { font-size: 22px; font-weight: 800; color: var(--navy); margin-bottom: 24px; }
.install-brand span { color: var(--orange); }

.install-steps { display: flex; gap: 8px; margin-bottom: 28px; }
.install-step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 3px solid var(--grey);
}
.install-step span {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}
.install-step.active { color: var(--navy); border-color: var(--orange); }
.install-step.done { color: var(--blue); border-color: var(--blue); }

.req-list { list-style: none; padding: 0; margin: 16px 0; }
.req-list li { padding: 8px 0; font-size: 14px; }
.req-list li.ok { color: var(--success); }
.req-list li.fail { color: var(--danger); }

.btn-row { display: flex; gap: 12px; margin-top: 20px; }

/* ---------------------------------------------------------------- */
/* Authenticated app shell                                           */
/* ---------------------------------------------------------------- */
.app-body { background: var(--light-grey); }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar-brand { font-size: 20px; font-weight: 800; padding: 0 24px 24px; }
.sidebar-brand span { color: var(--orange); }

.sidebar-nav { display: flex; flex-direction: column; flex: 1; }
.sidebar-nav a, .sidebar-footer a {
  padding: 13px 24px;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-footer a:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.sidebar-nav a.active, .sidebar-footer a.active {
  background: rgba(255,255,255,0.08);
  color: var(--white);
  border-left-color: var(--orange);
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 12px; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-topbar {
  background: var(--white);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--grey);
}
.app-topbar h1 { font-size: 20px; margin: 0; }
.topbar-user { text-align: right; }
.topbar-name { display: block; font-weight: 700; font-size: 14px; }
.topbar-role { display: block; font-size: 12px; color: var(--text-muted); }

.app-content { padding: 32px; flex: 1; }

.content-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }

/* stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--grey);
}
.stat-card.accent-orange { border-top-color: var(--orange); }
.stat-card.accent-blue { border-top-color: var(--blue); }
.stat-card.accent-navy { border-top-color: var(--navy); }
.stat-card.accent-grey { border-top-color: var(--grey); }
.stat-value { font-size: 32px; font-weight: 800; color: var(--navy); }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 600; margin-top: 4px; }

.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 24px; }

.panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-narrow { max-width: 480px; }

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

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-navy { background: var(--navy); color: var(--white); }
.badge-success { background: #E9F7EF; color: var(--success); }
.badge-warning { background: #FFF3E0; color: var(--warning); }
.badge-danger { background: #FDECEC; color: var(--danger); }
.badge-default { background: var(--light-grey); color: var(--text-muted); }

/* card grid: users, modules */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.user-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
}
.user-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.user-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--orange); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.user-name { font-weight: 700; font-size: 15px; }
.user-uid { font-size: 12px; color: var(--text-muted); }
.user-card-body div { font-size: 13px; padding: 4px 0; }
.user-card-footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--light-grey); }

.module-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--orange);
}
.module-process-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--light-grey);
  margin-top: 10px;
}

/* permission matrix */
.perm-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.perm-table th, .perm-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--light-grey); font-size: 14px; }
.perm-table th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--orange); }
.checkbox-inline { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0; }
.checkbox-inline input { width: 16px; height: 16px; accent-color: var(--orange); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }

/* modal */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center; justify-content: center;
  z-index: 50;
}
.modal.open { display: flex; }
.modal-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .login-card { grid-template-columns: 1fr; }
  .login-right { display: none; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { display: flex; border-top: none; padding-top: 0; margin-left: auto; }
  .form-grid { grid-template-columns: 1fr; }
}
