/* Familiar mailbox controls, using Elastic's own responsive behavior. */
:root {
  --apil-forest: #123e33;
  --apil-gold: #dfbd67;
  --apil-page: #f3f6f2;
  --apil-surface: #fff;
  --apil-sidebar: #f0f4ee;
  --apil-search: #eaf0e6;
  --apil-line: #dce5d9;
  --apil-ink: #233b2e;
  --apil-muted: #526c5a;
  --apil-selected: #dce9d7;
  --apil-hover: #edf3e9;
  --apil-focus: #2e674b;
  --apil-read: #f8faf6;
}

html.dark-mode {
  --apil-page: #101c16;
  --apil-surface: #1a2a20;
  --apil-sidebar: #142219;
  --apil-search: #243b2b;
  --apil-line: #364b3b;
  --apil-ink: #edf3e8;
  --apil-muted: #b1c2ad;
  --apil-selected: #32533b;
  --apil-hover: #29432f;
  --apil-focus: #dfbd67;
  --apil-read: #16251b;
}

body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

#logo {
  /* Hide the attachment's outer picture frame while keeping the mark intact. */
  clip-path: circle(42%);
  object-fit: cover;
}

/* Original mark, clean login form and readable accents in both themes. */
:is(html, html.dark-mode) body.task-login,
:is(html, html.dark-mode) body.task-login #layout-content {
  background: var(--apil-page);
  color: var(--apil-ink);
}

body.task-login #logo {
  width: 112px;
  height: 112px;
  max-height: 112px;
  border-radius: 50%;
  margin-bottom: 26px;
}

:is(html, html.dark-mode) body.task-login #login-form {
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 30px;
  border: 1px solid var(--apil-line);
  border-radius: 22px;
  background: var(--apil-surface);
  box-shadow: 0 12px 40px rgb(18 62 51 / 6%);
}

:is(html, html.dark-mode) body.task-login #login-footer {
  color: var(--apil-muted);
}

body.task-login .input-group {
  margin-bottom: 12px;
}

:is(html, html.dark-mode) body.task-login .input-group-text {
  background: var(--apil-sidebar);
  color: var(--apil-muted);
  border-color: var(--apil-line);
}

:is(html, html.dark-mode) body.task-login .form-control {
  min-height: 44px;
  color: var(--apil-ink);
  background: var(--apil-surface);
  border-color: var(--apil-line);
}

body.task-login #rcmloginsubmit {
  min-height: 44px;
  margin-top: 8px;
  color: var(--apil-forest);
  background: var(--apil-gold);
  border-color: var(--apil-gold);
  border-radius: 10px;
  font-weight: 700;
}

body.task-login #rcmloginsubmit:hover {
  background: #e8c97f;
  border-color: #e8c97f;
}

.apilsin-remember {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  margin: 4px 0;
  color: var(--apil-ink);
  font-size: 14px;
  cursor: pointer;
}

.apilsin-remember label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  margin: 0;
  cursor: pointer;
}

.apilsin-remember input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--apil-focus);
}

.apilsin-remember small {
  padding-inline-start: 26px;
  color: var(--apil-muted);
  font-size: 12px;
  line-height: 1.6;
}

/* Elastic enhances login inputs as icon groups; this one remains a real checkbox. */
#login-form .apilsin-remember .custom-control {
  display: flex !important;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  margin: 0;
  padding: 0 !important;
  border: 0;
  background: transparent;
}

#login-form .apilsin-remember #apilsin-remember {
  display: inline-block !important;
  position: static !important;
  z-index: auto;
  flex: 0 0 17px;
  width: 17px !important;
  height: 17px !important;
  min-height: 17px;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 1 !important;
  appearance: auto;
  box-shadow: none;
  accent-color: var(--apil-focus);
}

#login-form .apilsin-remember .input-group-prepend {
  display: none !important;
}

#login-form .apilsin-remember .custom-control-label {
  display: block !important;
  margin: 0;
  padding: 0 !important;
  color: var(--apil-ink);
  font-size: 14px;
  line-height: 1.6;
}

#login-form .apilsin-remember .custom-control-label::before,
#login-form .apilsin-remember .custom-control-label::after {
  display: none !important;
}

/* Navigation remains native, including its phone drawer and floating Compose. */
:is(html, html.dark-mode) #layout,
:is(html, html.dark-mode) #layout-menu,
:is(html, html.dark-mode) #layout-menu .popover-header,
:is(html, html.dark-mode) #taskmenu .special-buttons {
  background-color: var(--apil-sidebar) !important;
}

#layout-menu .popover-header #logo {
  width: 56px;
  height: 56px;
  max-height: 56px;
  max-width: 56px;
  padding: 0;
}

.apilsin-brand-name {
  display: block;
  color: var(--apil-ink);
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.02em;
  direction: ltr;
}

#taskmenu a,
#taskmenu a.logout {
  color: var(--apil-muted) !important;
}

#taskmenu a:not(.disabled):hover,
#taskmenu a:not(.disabled):focus,
#taskmenu a.selected {
  color: var(--apil-ink) !important;
  background: var(--apil-selected) !important;
}

#taskmenu .action-buttons a.compose {
  color: var(--apil-forest) !important;
  background: var(--apil-gold) !important;
  font-weight: 700;
}

#taskmenu .action-buttons a.compose:hover,
#taskmenu .action-buttons a.compose:focus {
  background: #e8c97f !important;
}

#taskmenu a:focus-visible,
body.task-login a:focus-visible,
.btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--apil-focus);
  outline-offset: 2px;
}

:is(html, html.dark-mode) #layout-sidebar,
:is(html, html.dark-mode) #layout-sidebar > .header,
:is(html, html.dark-mode) #layout-sidebar > .footer {
  color: var(--apil-ink);
  background-color: var(--apil-sidebar);
  border-color: var(--apil-line);
}

:is(html, html.dark-mode) #layout-list,
:is(html, html.dark-mode) #layout-content,
:is(html, html.dark-mode) #layout > div > .header,
:is(html, html.dark-mode) #layout > div > .footer {
  color: var(--apil-ink);
  background-color: var(--apil-surface);
  border-color: var(--apil-line);
}

:is(html, html.dark-mode) #layout > div > .header a.button,
:is(html, html.dark-mode) #layout > div > .header .menu a,
:is(html, html.dark-mode) #layout > div > .footer a {
  color: var(--apil-muted);
}

#layout-sidebar .header-title.username {
  direction: ltr;
  unicode-bidi: plaintext;
  font-size: 13px;
  font-weight: 600;
}

#mailboxlist {
  padding: 10px 8px;
}

:is(html, html.dark-mode) #mailboxlist li > a {
  min-height: 42px;
  line-height: 42px;
  margin: 2px 0;
  border-radius: 22px;
  color: var(--apil-muted);
  border: 0;
}

:is(html, html.dark-mode) #mailboxlist li > a:hover {
  color: var(--apil-ink);
  background: var(--apil-hover);
}

:is(html, html.dark-mode) #mailboxlist li.selected > a,
:is(html, html.dark-mode) #mailboxlist li.selected > a:focus {
  color: var(--apil-ink);
  background: var(--apil-selected);
  font-weight: 700;
}

:is(html, html.dark-mode) #mailboxlist .unreadcount {
  color: var(--apil-ink);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

/* Search is the first obvious control above the inbox. */
body.task-mail.action-none #layout-list {
  flex: 1 !important;
  width: auto !important;
  max-width: none !important;
}

body.task-mail.action-none #layout-content {
  display: none !important;
}

body.task-mail.action-show #layout-content > .header {
  align-items: center;
  gap: 8px;
}

body.task-mail.action-show #layout-content > .header > a.back-list-button {
  display: flex !important;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  align-self: center;
  order: -1;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  line-height: 44px;
  border-radius: 9px;
}

body.task-mail.action-show #layout-content > .header > a.back-list-button::before {
  float: none !important;
  width: 24px !important;
  height: 24px !important;
  margin: 0 !important;
  line-height: 24px;
}

body.task-mail.action-show #layout-content > .header > a.back-list-button .inner {
  display: none !important;
}

:is(html, html.dark-mode) body.task-mail #layout-list > .searchbar {
  height: 46px;
  min-height: 46px;
  margin: 10px 12px;
  line-height: 46px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: var(--apil-search);
}

body.task-mail #layout-list > .searchbar:focus-within {
  border-color: var(--apil-focus);
  box-shadow: 0 0 0 2px rgb(46 103 75 / 12%);
}

:is(html, html.dark-mode) body.task-mail #layout-list > .searchbar input {
  height: 44px;
  color: var(--apil-ink);
  font-size: 15px;
}

body.task-mail #layout-list > .searchbar input::placeholder {
  color: var(--apil-muted);
  opacity: 1;
}

:is(html, html.dark-mode) body.task-mail #layout-list > .searchbar a,
:is(html, html.dark-mode) body.task-mail #layout-list > .searchbar form::before {
  color: var(--apil-muted);
}

:is(html, html.dark-mode) #messagelist {
  color: var(--apil-ink);
  border-color: var(--apil-line);
}

:is(html, html.dark-mode) #messagelist tr td {
  height: auto;
  padding-block: 8px;
  color: var(--apil-muted);
  background: var(--apil-read);
  border-bottom-color: var(--apil-line);
}

#messagelist td.subject {
  min-height: 64px;
  align-content: center;
  row-gap: 2px;
}

#messagelist td.subject > span {
  line-height: 1.5;
}

:is(html, html.dark-mode) #messagelist tr.unread td {
  color: var(--apil-ink);
  background: var(--apil-surface);
  font-weight: 700;
}

:is(html, html.dark-mode) #messagelist tr:hover td {
  background: var(--apil-hover);
}

:is(html, html.dark-mode) #messagelist tr.selected td,
:is(html, html.dark-mode) #messagelist tr.focused td {
  color: var(--apil-ink);
  background: var(--apil-selected);
}

#messagelist .subject,
#messagelist .fromto {
  font-size: 14px;
}

#messagelist .date {
  font-size: 12px;
}

:is(html, html.dark-mode) #messagelist tr:not(.flagged):not(.deleted) .subject a {
  color: var(--apil-ink);
}

:is(html, html.dark-mode) #messagelist tr:not(.flagged):not(.deleted) .fromto,
:is(html, html.dark-mode) #messagelist tr:not(.flagged):not(.deleted) .date {
  color: var(--apil-muted);
}

:is(html, html.dark-mode) #messagelist tr.unread:not(.flagged):not(.deleted) .fromto {
  color: var(--apil-ink);
  font-weight: 600;
}

#messagelist-content .listing-info {
  color: var(--apil-muted);
}

/* The sender's original message content is left intact. */
:is(html, html.dark-mode) #message-header {
  color: var(--apil-ink);
  border-color: var(--apil-line);
}

#message-header h2.subject {
  font-size: 22px;
  line-height: 1.5;
  font-weight: 600;
}

:is(html, html.dark-mode) .btn-primary,
:is(html, html.dark-mode) .btn-primary:not(:disabled):not(.disabled):active,
:is(html, html.dark-mode) .btn-primary:focus {
  color: var(--apil-forest);
  background: var(--apil-gold);
  border-color: var(--apil-gold);
  border-radius: 9px;
  font-weight: 600;
}

:is(html, html.dark-mode) .btn-primary:hover {
  color: var(--apil-forest);
  background: #e8c97f;
  border-color: #e8c97f;
}

:is(html, html.dark-mode) .form-control,
:is(html, html.dark-mode) .custom-select,
:is(html, html.dark-mode) .recipient-input {
  color: var(--apil-ink);
  background-color: var(--apil-surface);
  border-color: var(--apil-line);
  border-radius: 8px;
}

:is(html, html.dark-mode) .form-control:focus,
:is(html, html.dark-mode) .recipient-input.focus {
  color: var(--apil-ink);
  background-color: var(--apil-surface);
  border-color: var(--apil-focus);
  box-shadow: 0 0 0 2px rgb(46 103 75 / 14%);
}

#compose-attachments {
  border: 1px dashed var(--apil-line);
  border-radius: 14px;
}

/* Signature editor uses the same straightforward, familiar form treatment. */
.apilsin-signature-panel,
.apilsin-signature-form {
  color: var(--apil-ink);
}

.apilsin-signature-panel {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px;
}

.apilsin-signature-panel h1 {
  font-size: 22px;
  line-height: 1.5;
  font-weight: 600;
}

.apilsin-signature-panel h2 {
  margin-block: 24px 12px;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 600;
}

.apilsin-signature-intro,
.apilsin-signature-note {
  color: var(--apil-muted);
  line-height: 1.8;
}

.apilsin-signature-intro {
  margin-bottom: 20px;
  font-size: 15px;
}

.apilsin-signature-note {
  margin-block: 12px 18px;
  font-size: 13px;
}

.apilsin-signature-form {
  padding: 22px;
  border: 1px solid var(--apil-line);
  border-radius: 16px;
  background: var(--apil-surface);
}

.apilsin-signature-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.apilsin-signature-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.apilsin-signature-form .form-control {
  min-height: 44px;
}

.apilsin-signature-preview {
  overflow-x: auto;
  padding: 20px;
  border: 1px solid var(--apil-line);
  border-radius: 12px;
  background: #fff;
  color: #123e33;
}

.apilsin-signature-preview tr,
.apilsin-signature-preview td {
  border-top: 0;
  background: transparent;
}

@media (min-width: 1025px) {
  .apilsin-signature-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #layout-menu {
    width: 96px;
    min-width: 96px;
  }

  #layout-menu .popover-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 92px;
    line-height: 1.5;
    gap: 4px;
  }

  #taskmenu a {
    width: 80px;
    max-width: 80px;
    min-height: 56px;
    margin: 4px 8px;
    padding: 9px 4px;
    border-radius: 13px;
  }

  #taskmenu span.inner {
    font-size: 12px;
  }

  #taskmenu .special-buttons {
    width: 96px;
    padding-bottom: 6px;
  }

  body.task-mail #layout-sidebar:not(.sidebar-right) {
    flex: 0 0 224px;
    min-width: 224px;
    max-width: 224px;
    border: 0;
  }

  body.task-mail #layout-list {
    margin-block: 12px;
    margin-inline-end: 12px;
    border: 1px solid var(--apil-line);
    border-radius: 16px;
    overflow: hidden;
  }

  body.task-mail.action-show #layout-content,
  body.task-mail.action-compose #layout-content {
    margin: 12px;
    border: 1px solid var(--apil-line);
    border-radius: 16px;
    overflow: hidden;
  }
}

@media (min-width: 481px) and (max-width: 1024px) {
  #layout-menu .popover-header #logo {
    width: 32px;
    height: 32px;
    max-width: 32px;
  }

  #layout-menu .apilsin-brand-name {
    display: none;
  }

  #taskmenu a {
    border-radius: 10px;
  }
}

@media (max-width: 768px) {
  body.task-mail #layout-list > .searchbar {
    margin: 8px 10px;
  }

  #messagelist tr td {
    height: auto;
    min-height: 54px;
  }

  #message-header h2.subject {
    font-size: 19px;
  }

  .apilsin-signature-panel {
    padding: 16px;
  }

  .apilsin-signature-form,
  .apilsin-signature-preview {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  body.task-login #login-form {
    padding: 24px;
  }

  #layout-menu .apilsin-brand-name {
    margin-inline: 8px;
  }

  #taskmenu a {
    margin: 3px 8px;
    border-radius: 10px;
  }

  :is(html, html.dark-mode) .floating-action-buttons a.compose {
    color: var(--apil-forest);
    background: var(--apil-gold);
  }
}
