body.terminal-mode {
  margin: 0;
  overflow: hidden;
  background: #ffffff;
}

body.terminal-mode > :not(#screen-terminal):not(script) {
  display: none !important;
}

.terminal-screen[hidden] {
  display: none !important;
}

.terminal-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: #ffffff;
  color: #17382b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.terminal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 32px;
  min-height: 126px;
  padding: 24px 40px;
  border-top: 10px solid #e76654;
  border-bottom: 1px solid #d8e5dc;
  background: #ffffff;
}

.terminal-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 24px;
}

.terminal-brand img {
  width: 174px;
  height: auto;
  flex: 0 0 auto;
}

.terminal-brand div {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.terminal-brand span,
.terminal-status-label,
.terminal-footer {
  font-weight: 800;
}

.terminal-brand span {
  color: #5a6d63;
  font-size: 18px;
}

.terminal-brand h1 {
  margin: 0;
  color: #17382b;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

.terminal-datetime {
  display: grid;
  justify-items: end;
  min-width: 290px;
  gap: 3px;
}

.terminal-time {
  color: #0d684b;
  font-size: 64px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.terminal-date {
  color: #4e6257;
  font-size: 19px;
  font-weight: 750;
  white-space: nowrap;
}

.terminal-main {
  display: grid;
  grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
  align-items: center;
  gap: 54px;
  min-height: 0;
  padding: 34px 7vw;
  background: #f3f8f4;
}

.terminal-visual {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 14px;
}

.terminal-scan-indicator {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 250px;
  height: 310px;
  border: 12px solid #0d684b;
  border-radius: 8px;
  outline: 18px solid #dfeee4;
  background: #ffffff;
  color: #17382b;
  box-shadow: 0 18px 38px rgba(23, 56, 43, .14);
}

.terminal-scan-indicator img {
  width: 132px;
  height: 132px;
  object-fit: contain;
}

.terminal-copy {
  display: grid;
  align-content: center;
  max-width: 820px;
  gap: 16px;
}

.terminal-status-label {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  margin: 0;
  padding: 8px 16px;
  border-left: 8px solid #f0bd36;
  background: #fff6d9;
  color: #604900;
  font-size: 20px;
}

.terminal-screen[data-nfc-state="choice"] .terminal-status-label {
  min-height: 30px;
  padding: 5px 10px;
  border-left-width: 5px;
  font-size: 14px;
}

.terminal-copy h2 {
  max-width: 13ch;
  margin: 0;
  color: #17382b;
  font-size: 74px;
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: 0;
}

#terminal-message {
  margin: 0;
  color: #52675b;
  font-size: 26px;
  font-weight: 720;
  line-height: 1.35;
}

.terminal-punky-briefing[hidden] {
  display: none !important;
}

.terminal-punky-briefing {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  max-width: 680px;
  padding: 14px 18px;
  border: 1px solid #c9dfcf;
  border-left: 7px solid #0d684b;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(23, 56, 43, .08);
}

.terminal-punky-briefing[data-state="attention"] { border-left-color: #d95f45; }
.terminal-punky-briefing[data-state="reminder"] { border-left-color: #d39b12; }
.terminal-punky-briefing[data-state="ok"] { border-left-color: #0d684b; }

.terminal-punky-briefing img {
  width: 76px;
  height: 94px;
  object-fit: contain;
}

.terminal-punky-briefing > div { display: grid; gap: 5px; }
.terminal-punky-briefing p { margin: 0; }
#terminal-punky-label { color: #0d684b; font-size: 14px; font-weight: 900; }
#terminal-punky-title { color: #17382b; font-size: 20px; line-height: 1.2; }
#terminal-punky-communication,
#terminal-punky-word { color: #52675b; font-size: 16px; font-weight: 700; line-height: 1.3; }
#terminal-punky-communication { white-space: pre-line; }
#terminal-punky-facts { display: grid; gap: 3px; margin: 0; padding-left: 18px; color: #17382b; font-size: 16px; font-weight: 800; }

.terminal-auth-form[hidden] {
  display: none !important;
}

.terminal-auth-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: min(100%, 680px);
  margin-top: 8px;
}

.terminal-auth-form label {
  display: grid;
  gap: 7px;
  color: #17382b;
  font-size: 16px;
  font-weight: 800;
}

.terminal-auth-form input {
  width: 100%;
  min-height: 54px;
  border: 2px solid #afc4b6;
  border-radius: 6px;
  padding: 10px 14px;
  background: #ffffff;
  color: #17382b;
  font: inherit;
  font-size: 18px;
}

.terminal-auth-form input:focus {
  border-color: #0d684b;
  outline: 3px solid rgba(13, 104, 75, .18);
}

.terminal-auth-form button {
  grid-column: 1 / -1;
  min-height: 56px;
  border: 0;
  border-radius: 6px;
  padding: 12px 18px;
  background: #0d684b;
  color: #ffffff;
  font: inherit;
  font-size: 19px;
  font-weight: 850;
  cursor: pointer;
}

.terminal-auth-form button:disabled {
  cursor: wait;
  opacity: .65;
}

#terminal-auth-message {
  grid-column: 1 / -1;
  min-height: 24px;
  margin: 0;
  color: #9b2f28;
  font-size: 16px;
  font-weight: 750;
}

.terminal-screen:is(
  [data-access-state="checking"],
  [data-access-state="auth-required"],
  [data-access-state="unauthorized"],
  [data-access-state="error"]
) .terminal-main {
  grid-template-columns: 1fr;
}

.terminal-screen:is(
  [data-access-state="checking"],
  [data-access-state="auth-required"],
  [data-access-state="unauthorized"],
  [data-access-state="error"]
) .terminal-visual {
  display: none;
}

.terminal-screen:is(
  [data-access-state="checking"],
  [data-access-state="auth-required"],
  [data-access-state="unauthorized"],
  [data-access-state="error"]
) .terminal-copy {
  justify-self: center;
  width: min(100%, 720px);
}

.terminal-screen:is(
  [data-access-state="checking"],
  [data-access-state="auth-required"],
  [data-access-state="unauthorized"],
  [data-access-state="error"]
) .terminal-copy h2 {
  max-width: 15ch;
  font-size: 58px;
}

.terminal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 58px;
  padding: 12px 40px;
  border-top: 1px solid #d8e5dc;
  background: #17382b;
  color: #ffffff;
  font-size: 17px;
}

.terminal-screen[data-state="confirmation"] .terminal-scan-indicator {
  border-color: #2e7d49;
  outline-color: #d8efdf;
}

.terminal-screen[data-state="processing"] .terminal-scan-indicator {
  border-color: #d09a13;
  outline-color: #fff0bd;
}

.terminal-attendance[hidden] {
  display: none !important;
}

.terminal-attendance {
  display: grid;
  width: min(100%, 720px);
  gap: 12px;
  margin-top: 4px;
}

.terminal-attendance-types[hidden],
.terminal-attendance-profile[hidden],
.terminal-attendance-activate[hidden] {
  display: none !important;
}

.terminal-attendance-profile {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 250px;
  padding: 4px 10px;
  color: #17382b;
  text-align: center;
}

.terminal-attendance-profile strong {
  font-size: clamp(20px, 2.8vh, 28px);
  line-height: 1.15;
}

.terminal-attendance-profile strong[data-attendance-state="working"] {
  color: #167342;
}

.terminal-attendance-profile strong[data-attendance-state="break"] {
  color: #8a6300;
}

.terminal-attendance-profile strong[data-attendance-state="finished"] {
  color: #8c2f2a;
}

.terminal-attendance-profile span {
  min-height: 19px;
  font-size: 16px;
  font-weight: 800;
}

.terminal-attendance-reader {
  margin: 0;
  color: #52675b;
  font-size: 17px;
  font-weight: 750;
  line-height: 1.35;
}

.terminal-attendance-types {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.terminal-attendance-types[data-action-count="1"] button:not([hidden]) {
  grid-column: 1 / -1;
  width: 100%;
}

.terminal-attendance-types button,
.terminal-attendance-activate {
  min-height: 72px;
  border: 3px solid #0d684b;
  border-radius: 6px;
  padding: 12px 20px;
  background: #ffffff;
  color: #0d684b;
  font: inherit;
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
}

.terminal-attendance-types button {
  display: grid;
  place-content: center;
  gap: 3px;
  line-height: 1.1;
}

.terminal-attendance-types button strong {
  font-size: inherit;
}

.terminal-attendance-types button span {
  font-size: 15px;
  font-weight: 750;
}

.terminal-attendance-types button[data-attendance-type="entry"],
.terminal-attendance-types button[data-attendance-type="break_end"] {
  background: #0d684b;
  color: #ffffff;
}

.terminal-attendance-types button[data-attendance-type="break_start"] {
  border-color: #9a7000;
  background: #f7d56f;
  color: #4f3a00;
}

.terminal-attendance-types button[data-attendance-type="exit"] {
  border-color: #b54135;
  background: #fff5f2;
  color: #9b2f28;
}

.terminal-attendance-types button[aria-pressed="true"] {
  box-shadow: 0 0 0 6px rgba(23, 56, 43, .18);
  filter: brightness(.92);
}

.terminal-attendance-types button:disabled,
.terminal-attendance-activate:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.terminal-attendance-activate {
  min-height: 86px;
  border-width: 3px;
  background: #17382b;
  color: #ffffff;
  font-size: 30px;
}

.terminal-attendance-reader {
  min-height: 25px;
  color: #17382b;
}

.terminal-screen[data-state="error"] .terminal-scan-indicator {
  border-color: #b33b32;
  outline-color: #f6deda;
}

.terminal-nfc-diagnostic[hidden] {
  display: none !important;
}

.terminal-screen[data-view="nfc-diagnostic"] .terminal-main {
  grid-template-columns: 1fr;
  padding: 20px 4vw;
}

.terminal-screen[data-view="nfc-diagnostic"] .terminal-visual {
  display: none;
}

.terminal-screen[data-view="nfc-diagnostic"] .terminal-copy {
  width: min(100%, 1180px);
  max-width: none;
  justify-self: center;
  gap: 8px;
}

.terminal-screen[data-view="nfc-diagnostic"] .terminal-copy h2 {
  max-width: none;
  font-size: 42px;
}

.terminal-screen[data-view="nfc-diagnostic"] #terminal-message {
  font-size: 18px;
}

.terminal-nfc-diagnostic {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 4px;
}

.terminal-nfc-overview,
.terminal-nfc-result {
  display: grid;
  gap: 10px;
}

.terminal-nfc-overview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.terminal-nfc-result {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.terminal-nfc-overview > div,
.terminal-nfc-result > div {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid #c8d9cd;
  border-radius: 6px;
  background: #ffffff;
}

.terminal-nfc-overview span,
.terminal-nfc-result span {
  color: #5a6d63;
  font-size: 13px;
  font-weight: 800;
}

.terminal-nfc-overview strong,
.terminal-nfc-result strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #17382b;
  font-size: 18px;
  letter-spacing: 0;
}

.terminal-nfc-result strong[data-stability="stable"] {
  color: #17613f;
}

.terminal-nfc-result strong[data-stability="different"],
.terminal-nfc-result strong[data-stability="absent"] {
  color: #a2322b;
}

.terminal-nfc-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.terminal-nfc-actions button {
  min-height: 58px;
  border: 2px solid #0d684b;
  border-radius: 6px;
  padding: 10px 20px;
  background: #0d684b;
  color: #ffffff;
  font: inherit;
  font-size: 20px;
  font-weight: 850;
  cursor: pointer;
}

.terminal-nfc-actions button:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.terminal-nfc-actions .terminal-nfc-reset {
  background: #ffffff;
  color: #0d684b;
}

.terminal-nfc-history-block {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.terminal-nfc-history-block h3 {
  margin: 0;
  color: #17382b;
  font-size: 16px;
  letter-spacing: 0;
}

.terminal-nfc-history-block ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.terminal-nfc-history-block li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-left: 5px solid #0d684b;
  background: #e8f2eb;
  color: #17382b;
  font-size: 14px;
}

.terminal-nfc-history-block li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-nfc-history-block li time {
  color: #52675b;
  font-variant-numeric: tabular-nums;
}

.terminal-nfc-history-block .terminal-nfc-history-empty {
  grid-column: 1 / -1;
  display: block;
  border-left-color: #9bad9f;
  background: #edf2ee;
  color: #52675b;
}

@media (orientation: portrait) and (max-width: 900px) {
  .terminal-header {
    min-height: 116px;
    padding: 22px 28px;
  }

  .terminal-brand {
    gap: 18px;
  }

  .terminal-brand img {
    width: 138px;
  }

  .terminal-brand span {
    font-size: 15px;
  }

  .terminal-brand h1 {
    font-size: 28px;
  }

  .terminal-datetime {
    min-width: 205px;
  }

  .terminal-time {
    font-size: 54px;
  }

  .terminal-date {
    max-width: 220px;
    font-size: 16px;
    text-align: right;
    white-space: normal;
  }

  .terminal-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(200px, .9fr) minmax(0, 1fr);
    justify-items: center;
    gap: 30px;
    padding: 40px 7vw;
    text-align: center;
  }

  .terminal-screen:is(
    [data-access-state="checking"],
    [data-access-state="auth-required"],
    [data-access-state="unauthorized"],
    [data-access-state="error"]
  ) .terminal-main {
    grid-template-rows: 1fr;
  }

  .terminal-scan-indicator {
    justify-self: center;
    width: 220px;
    height: 260px;
  }

  .terminal-visual {
    justify-items: center;
  }

  .terminal-scan-indicator img {
    width: 116px;
    height: 116px;
  }

  .terminal-copy {
    justify-items: center;
  }

  .terminal-status-label {
    justify-self: center;
  }

  .terminal-copy h2 {
    max-width: 12ch;
    font-size: 64px;
  }

  .terminal-screen[data-view="attendance"] .terminal-main {
    grid-template-rows: minmax(160px, .65fr) minmax(0, 1fr);
    gap: 20px;
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .terminal-screen[data-view="attendance"] .terminal-scan-indicator {
    width: 170px;
    height: 190px;
  }

  .terminal-screen[data-view="attendance"] .terminal-attendance-profile {
    width: 170px;
  }

  .terminal-screen[data-view="attendance"] .terminal-copy {
    gap: 10px;
  }

  .terminal-screen[data-view="attendance"] .terminal-copy h2 {
    max-width: none;
    font-size: 44px;
  }

  .terminal-screen[data-view="attendance"] #terminal-message {
    font-size: 21px;
  }

  .terminal-screen:is(
    [data-access-state="checking"],
    [data-access-state="auth-required"],
    [data-access-state="unauthorized"],
    [data-access-state="error"]
  ) .terminal-copy h2 {
    font-size: 52px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-main {
    grid-template-rows: 1fr;
    align-items: start;
    padding: 24px 28px;
    text-align: left;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-copy {
    justify-items: stretch;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-status-label {
    justify-self: start;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-copy h2 {
    font-size: 38px;
  }

  .terminal-nfc-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .terminal-nfc-overview > div:last-child {
    grid-column: 1 / -1;
  }

  .terminal-nfc-history-block ol {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .terminal-header {
    gap: 14px;
    min-height: 94px;
    padding: 16px 20px;
    border-top-width: 7px;
  }

  .terminal-brand img {
    width: 92px;
  }

  .terminal-brand span {
    display: none;
  }

  .terminal-brand h1 {
    font-size: 24px;
  }

  .terminal-datetime {
    min-width: 130px;
  }

  .terminal-time {
    font-size: 42px;
  }

  .terminal-date {
    max-width: 150px;
    font-size: 13px;
  }

  .terminal-main {
    grid-template-rows: minmax(160px, .75fr) minmax(0, 1fr);
    gap: 22px;
    padding: 28px 24px;
  }

  .terminal-attendance-types button {
    min-height: 62px;
    padding-inline: 10px;
    font-size: 21px;
  }

  .terminal-attendance-reader {
    font-size: 15px;
  }

  .terminal-scan-indicator {
    width: 160px;
    height: 190px;
    border-width: 9px;
    outline-width: 12px;
  }

  .terminal-scan-indicator img {
    width: 86px;
    height: 86px;
  }

  .terminal-status-label {
    min-height: 38px;
    font-size: 17px;
  }

  .terminal-copy h2 {
    font-size: 48px;
  }

  #terminal-message {
    font-size: 21px;
  }

  .terminal-auth-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .terminal-footer {
    min-height: 50px;
    padding: 10px 20px;
    font-size: 14px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-main {
    padding: 18px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-copy h2 {
    font-size: 32px;
  }

  .terminal-nfc-overview,
  .terminal-nfc-result,
  .terminal-nfc-actions {
    grid-template-columns: 1fr;
  }

  .terminal-nfc-overview > div:last-child {
    grid-column: auto;
  }

  .terminal-nfc-actions button {
    min-height: 52px;
    font-size: 17px;
  }
}

@media (orientation: landscape) and (max-height: 650px) {
  .terminal-header {
    min-height: 92px;
    padding: 14px 28px;
    border-top-width: 7px;
  }

  .terminal-brand img {
    width: 124px;
  }

  .terminal-brand span {
    font-size: 14px;
  }

  .terminal-brand h1 {
    font-size: 26px;
  }

  .terminal-datetime {
    min-width: 230px;
  }

  .terminal-time {
    font-size: 50px;
  }

  .terminal-date {
    font-size: 15px;
  }

  .terminal-main {
    grid-template-columns: minmax(210px, 32%) minmax(0, 1fr);
    gap: 42px;
    padding: 24px 7vw;
  }

  .terminal-screen:is(
    [data-access-state="checking"],
    [data-access-state="auth-required"],
    [data-access-state="unauthorized"],
    [data-access-state="error"]
  ) .terminal-main {
    grid-template-columns: 1fr;
  }

  .terminal-scan-indicator {
    width: 174px;
    height: 206px;
    border-width: 9px;
    outline-width: 12px;
  }

  .terminal-attendance-profile {
    width: 174px;
  }

  .terminal-scan-indicator img {
    width: 90px;
    height: 90px;
  }

  .terminal-status-label {
    min-height: 36px;
    font-size: 16px;
  }

  .terminal-copy h2 {
    font-size: 54px;
  }

  .terminal-screen:is(
    [data-access-state="checking"],
    [data-access-state="auth-required"],
    [data-access-state="unauthorized"],
    [data-access-state="error"]
  ) .terminal-copy h2 {
    font-size: 44px;
  }

  #terminal-message {
    font-size: 20px;
  }

  .terminal-attendance {
    gap: 8px;
  }

  .terminal-attendance-types {
    gap: 8px;
  }

  .terminal-attendance-types button {
    min-height: 52px;
    padding: 8px 12px;
    font-size: 20px;
  }

  .terminal-attendance-activate {
    min-height: 66px;
    font-size: 25px;
  }

  .terminal-attendance-reader {
    min-height: 20px;
    font-size: 14px;
  }

  .terminal-footer {
    min-height: 46px;
    padding: 8px 28px;
    font-size: 14px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-main {
    grid-template-columns: 1fr;
    padding: 10px 28px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-copy {
    gap: 4px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] .terminal-copy h2 {
    font-size: 30px;
  }

  .terminal-screen[data-view="nfc-diagnostic"] #terminal-message {
    font-size: 14px;
  }

  .terminal-nfc-diagnostic {
    gap: 7px;
  }

  .terminal-nfc-overview > div,
  .terminal-nfc-result > div {
    padding: 6px 10px;
  }

  .terminal-nfc-overview strong,
  .terminal-nfc-result strong {
    font-size: 15px;
  }

  .terminal-nfc-actions button {
    min-height: 44px;
    padding: 6px 14px;
    font-size: 16px;
  }

  .terminal-nfc-history-block li {
    padding: 5px 8px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .terminal-screen * {
    scroll-behavior: auto !important;
  }
}
