:root {
  --navy: #102a37;
  --navy-soft: #193b48;
  --teal: #13756f;
  --teal-dark: #0d5c57;
  --gold: #f0b761;
  --ink: #172a34;
  --muted: #60747d;
  --line: #d8e3e3;
  --surface: #fff;
  --canvas: #f3f6f5;
  --soft: #ebf3f1;
  --danger: #ac3640;
  --shadow: 0 12px 35px rgba(16, 42, 55, .07);
  --radius: 16px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { font-family: "Segoe UI", Arial, sans-serif; color: var(--ink); }
body { margin: 0; background: var(--canvas); }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, textarea:disabled { opacity: .62; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { color: var(--muted); font-size: .76rem; font-weight: 650; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  background: white;
  color: var(--ink);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 3px solid rgba(19,117,111,.12);
  border-color: var(--teal);
}
.primary, .secondary {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 13px;
  font-weight: 650;
}
.primary { color: white; background: var(--teal); }
.primary:hover { background: var(--teal-dark); }
.secondary { color: var(--teal-dark); background: var(--soft); border-color: #d2e1df; }
.full { width: 100%; }
.eyebrow { color: var(--teal); font-size: .68rem; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 7px; }
.helper { color: var(--muted); font-size: .83rem; line-height: 1.46; }
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy), #173a47 46%, #eff4f2 46%);
  display: grid;
  align-content: center;
  justify-content: center;
  gap: 28px;
  grid-template-columns: minmax(280px, 380px) minmax(300px, 420px);
  padding: 22px;
}
.login-brand { color: white; display: flex; gap: 17px; align-items: center; }
.login-brand h1 { font-size: 2.05rem; line-height: 1.1; }
.login-brand p { color: #bed0d3; margin-top: 8px; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 54px;
  height: 54px;
  border-radius: 15px;
  color: var(--navy);
  background: var(--gold);
  font-weight: 800;
}
.login-card {
  background: white;
  border-radius: 22px;
  box-shadow: 0 28px 70px rgba(6,20,28,.2);
  padding: 31px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card h2 { font-size: 1.52rem; }
.form-error { min-height: 18px; font-size: .8rem; color: var(--danger); }
.login-status { min-height: 18px; font-size: .82rem; color: var(--muted); }
.login-status.working { color: var(--teal-dark); font-weight: 650; }
.password-control { display: flex; gap: 7px; align-items: stretch; }
.password-control input { flex: 1; }
.password-toggle { flex: 0 0 auto; padding: 8px 11px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 282px minmax(460px, 1fr) 332px; }
.mobile-header { display: none; }
.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--navy);
  color: #eff7f5;
  padding: 25px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 1.13rem; line-height: 1.16; }
.brand p { color: #b5c9cc; font-size: .78rem; margin-top: 4px; }
.search-field span { color: #b8cbce; }
.search-field input { background: var(--navy-soft); border-color: #36515d; color: #fff; }
.search-field input::placeholder { color: #9fb3b7; }
.side-heading { color: #abc1c4; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 13px; }
.company-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.company-btn {
  border: 1px solid transparent; border-radius: 12px; padding: 13px 12px;
  background: transparent; color: white; text-align: left; display: flex; gap: 10px;
}
.company-btn:hover, .company-btn.active { background: var(--navy-soft); border-color: #36515d; }
.company-btn:before { content: ""; flex: 0 0 7px; background: #37818a; border-radius: 8px; }
.company-btn.active:before { background: var(--gold); }
.company-btn strong { display: block; }
.company-btn small { display: block; color: #aec2c6; margin-top: 3px; }
.sidebar-footer { border-top: 1px solid #294653; padding-top: 14px; display: flex; flex-direction: column; gap: 5px; font-size: .83rem; }
.sidebar-footer span { color: #b8cbce; }
.text-btn { border: 0; color: var(--gold); background: none; text-align: left; padding: 12px 0 0; }
.workspace { min-width: 0; padding: 21px; display: flex; flex-direction: column; gap: 15px; }
#company-workspace { display: flex; flex-direction: column; gap: 15px; flex: 1; }
.settings {
  background: #e9f0ee; border-left: 1px solid var(--line); padding: 21px 16px;
  display: flex; flex-direction: column; gap: 14px; overflow-y: auto;
}
.card { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.welcome { margin: auto 0; text-align: center; padding: 58px 25px; }
.welcome h2 { margin-bottom: 10px; font-size: 1.42rem; }
.company-fields { display: flex; gap: 12px; align-items: end; margin-bottom: 12px; }
.grow { flex: 1; }
.title-input { font-weight: 700; font-size: 1.25rem; }
.page-nav .section-heading { margin-bottom: 15px; }
.page-tabs { display: flex; overflow-x: auto; gap: 8px; }
.page-tab {
  white-space: nowrap; border: 1px solid var(--line); padding: 9px 14px; border-radius: 10px;
  background: white; color: var(--muted);
}
.page-tab.active { color: white; background: var(--teal); border-color: var(--teal); }
.editor { flex: 1; }
.editor-empty { padding: 58px 20px; text-align: center; color: var(--muted); }
.editor-title { display: flex; gap: 14px; align-items: end; margin-bottom: 15px; }
.permission-pill { color: var(--teal-dark); background: #e7f3f0; border-radius: 999px; padding: 9px 12px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.permission-pill.view { background: #f7f0e5; color: #865b20; }
.block-toolbar { border: 1px dashed #cadaD8; border-radius: 12px; background: #f6f9f8; padding: 10px; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 13px; }
.block-toolbar span { color: var(--muted); font-size: .8rem; margin-right: 5px; }
.block-toolbar button { border: 1px solid #cfe0de; color: var(--teal-dark); background: white; padding: 7px 10px; border-radius: 9px; }
.blocks { display: flex; flex-direction: column; gap: 10px; }
.block { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: white; }
.block.note { border-left: 4px solid var(--gold); background: #fffaf1; }
.block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.block-kind { color: var(--teal-dark); background: var(--soft); border-radius: 7px; padding: 5px 8px; text-transform: uppercase; font-size: .68rem; font-weight: 750; }
.block-remove { margin-left: auto; border: 1px solid #ead4d6; color: var(--danger); background: white; padding: 5px 8px; border-radius: 8px; }
.block textarea, .block input[type="text"] { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px; }
.block textarea { min-height: 74px; resize: vertical; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.photo-card { background: linear-gradient(130deg,#176069,#79aaa2); color: white; min-height: 116px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 8px; }
.document { display: flex; gap: 10px; background: #f4f8f7; padding: 12px; border-radius: 9px; }
.doc-badge { color: var(--teal-dark); background: #d9ebe7; padding: 12px 8px; border-radius: 8px; font-weight: 750; }
.table-block { overflow-x: auto; }
.table-block table { border-collapse: collapse; width: 100%; margin-bottom: 9px; }
.table-block td { border: 1px solid var(--line); }
.table-block input { border: 0 !important; border-radius: 0 !important; background: transparent; }
.table-block tr:first-child { background: var(--soft); font-weight: 650; }
.row-actions { display: flex; gap: 7px; }
.checkitem { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.page-save { margin-top: 15px; }
.role-badge { display: inline-block; color: var(--teal-dark); background: var(--soft); border-radius: 99px; padding: 7px 11px; margin: 9px 0 15px; font-size: .82rem; font-weight: 650; }
.employee-list { display: flex; flex-direction: column; gap: 7px; margin: 13px 0; }
.user-row { display: flex; gap: 6px; align-items: stretch; }
.user-btn { flex: 1; border: 1px solid var(--line); background: #f6f9f8; border-radius: 10px; padding: 10px; text-align: left; }
.user-btn.active { border-color: var(--teal); }
.user-btn strong { display: block; }
.user-btn small { color: var(--muted); }
.revoke-btn { border: 1px solid #ecd6d8; background: #fff5f5; color: var(--danger); border-radius: 9px; padding: 7px; font-size: .75rem; }
#permission-editor h3 { margin: 10px 0; font-size: .95rem; }
.permission-grid { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 15px; }
.permission-row { display: grid; grid-template-columns: 1fr 95px; gap: 9px; align-items: center; font-size: .81rem; border-bottom: 1px solid #edf2f1; padding-bottom: 7px; }
.permission-row select { padding: 6px; border: 1px solid var(--line); border-radius: 7px; }
.timeline { list-style: none; margin: 13px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.timeline li { border-left: 2px solid #cdddda; padding-left: 9px; font-size: .78rem; color: var(--muted); }
.timeline strong { display: block; color: var(--ink); }
dialog { border: 0; border-radius: 16px; padding: 22px; width: min(450px, calc(100% - 28px)); box-shadow: 0 18px 60px rgba(8,25,33,.27); }
dialog::backdrop { background: rgba(12,30,37,.52); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
#prompt-fields { display: flex; flex-direction: column; gap: 12px; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; }
.toast { opacity: 0; pointer-events: none; position: fixed; bottom: 18px; right: 18px; background: var(--navy); color: white; border-radius: 11px; padding: 12px 17px; transform: translateY(12px); transition: .16s; }
.toast.show { opacity: 1; transform: none; }
@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 250px minmax(420px, 1fr); }
  .settings { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, 1fr); }
  #users-panel { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .login-screen { display: flex; flex-direction: column; background: var(--navy); min-height: 100dvh; }
  .login-brand h1 { font-size: 1.4rem; }
  .login-card { padding: 21px; }
  .secure-app { padding-top: 58px; }
  .mobile-header { position: fixed; display: flex; top: 0; left: 0; right: 0; height: 58px; align-items: center; justify-content: space-between; padding: 0 11px; background: var(--navy); color: white; z-index: 20; }
  .icon-btn { border: 1px solid #41606b; background: var(--navy-soft); color: white; border-radius: 8px; padding: 7px 9px; }
  .app-shell { display: block; min-height: unset; }
  .sidebar, .settings { display: none; position: fixed; z-index: 15; top: 58px; bottom: 0; height: auto; width: min(88vw, 335px); overflow-y: auto; }
  .sidebar.open { display: flex; left: 0; }
  .settings.open { display: flex; right: 0; padding: 13px; }
  .workspace { padding: 12px; overflow: hidden; }
  .card { padding: 13px; min-width: 0; overflow: hidden; }
  .company-fields, .editor-title { flex-direction: column; align-items: stretch; }
  .columns { grid-template-columns: 1fr; }
  .block-toolbar, .page-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .block-toolbar button, .block-toolbar span { white-space: nowrap; }
}
