@import url("https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;700&family=Roboto+Mono:wght@400;500&display=swap");

:root {
  --red: #cc0000;
  --red-bright: #ff1a1a;
  --red-dark: #8b0000;
  --bg: #111;
  --surface: #1a1a1a;
  --surface-soft: #232323;
  --text: #f0f0f0;
  --muted: #a6a6a6;
  --ok: #6fbf73;
  --warn: #ffbf47;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #1c1c1c 0%, #0d0d0d 60%);
  color: var(--text);
  font-family: "Oswald", sans-serif;
}

input,
button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.btn {
  background: #2b2b2b;
  color: var(--text);
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  border-color: var(--red-dark);
  color: #fff;
}

.btn-danger {
  background: #4a1e1e;
  border-color: #743030;
}

input {
  width: 100%;
  background: #0f0f0f;
  color: var(--text);
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  color: #d8d8d8;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.card {
  background: rgba(23, 23, 23, 0.95);
  border: 1px solid #2c2c2c;
  border-radius: 14px;
  padding: 1rem;
}

.error-text {
  color: var(--red-bright);
  margin-top: 0.6rem;
}

.auth-page,
.admin-page,
.phone-page {
  min-height: 100dvh;
}

/* Login */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(160deg, #181818, #0e0e0e);
  border: 1px solid #2a2a2a;
  border-radius: 28px;
  padding: 1.3rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.auth-card h1 {
  margin: 0;
  color: var(--red-bright);
  letter-spacing: 0.03em;
}

.auth-subtitle {
  margin-top: 0.25rem;
  color: var(--muted);
}

.auth-form {
  margin-top: 1rem;
}

.auth-form .btn {
  width: 100%;
  margin-top: 0.8rem;
  font-weight: 700;
}

/* Admin */
.admin-wrap {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1,
.card h2 {
  margin: 0;
  color: var(--red-bright);
}

.admin-grid-form {
  display: grid;
  gap: 0.8rem;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.8rem;
  font-family: "Roboto Mono", monospace;
  font-size: 0.84rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #2a2a2a;
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

.admin-actions {
  display: grid;
  gap: 0.4rem;
}

.transcript-row td {
  background: #131313;
}

.transcript-block {
  margin: 0;
  white-space: pre-wrap;
  font-family: "Roboto Mono", monospace;
  color: #d5d5d5;
}

.stats-row p {
  margin: 0.4rem 0;
}

/* Phone */
.phone-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
}

.flip-device {
  width: min(430px, 95vw);
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  border-radius: 28px;
  border: 2px solid #700;
  box-shadow:
    inset 0 -8px 18px rgba(0, 0, 0, 0.25),
    0 24px 42px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.flip-top {
  padding: 0.9rem;
  background: linear-gradient(180deg, #d30f0f, #aa0000);
  border-bottom: 3px solid #6f0000;
}

.screen-shell {
  background: #0b0b0b;
  border: 2px solid #3a3a3a;
  border-radius: 16px;
  min-height: 49dvh;
  max-height: 49dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen-status {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  background: #151515;
  border-bottom: 1px solid #222;
}

.icon-btn {
  background: transparent;
  border: none;
  color: #d7d7d7;
  cursor: pointer;
  font-size: 1rem;
}

.status-contact {
  text-align: center;
  color: #c7c7c7;
  letter-spacing: 0.03em;
}

.status-signal {
  color: #76cf7b;
  font-size: 0.9rem;
}

.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.55rem;
  display: grid;
  gap: 0.45rem;
  align-content: start;
  font-family: "Roboto Mono", monospace;
  font-size: 0.78rem;
}

.msg {
  max-width: 83%;
  border-radius: 12px;
  padding: 0.42rem 0.52rem;
  line-height: 1.35;
  word-break: break-word;
}

.msg-sent {
  justify-self: end;
  background: #3b3b3b;
  color: #f2f2f2;
}

.msg-received {
  justify-self: start;
  background: #1f2d1f;
  color: #d9f3d8;
}

.msg-error {
  justify-self: start;
  background: #3e2a12;
  color: #ffcf80;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.35rem;
  padding: 0.45rem;
  border-top: 1px solid #222;
  background: #101010;
  align-items: center;
}

.composer input {
  font-size: 0.85rem;
  padding: 0.42rem 0.48rem;
  border-radius: 8px;
}

.counter {
  font-size: 0.74rem;
  color: #a7a7a7;
  min-width: 46px;
  text-align: right;
  font-family: "Roboto Mono", monospace;
}

.counter-warn {
  color: var(--red-bright);
}

.send-btn {
  border: 1px solid #5a0000;
  background: linear-gradient(180deg, #ff3f3f, #c90000);
  color: #fff;
  border-radius: 8px;
  padding: 0.34rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.flip-bottom {
  background: linear-gradient(180deg, #cb0000 0%, #9f0000 100%);
  padding: 0.85rem;
  display: grid;
  gap: 0.9rem;
}

.dpad-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  gap: 0.5rem;
  align-items: center;
}

.dpad {
  display: grid;
  gap: 0.35rem;
}

.dpad-mid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem;
}

.num-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.key {
  border: 1px solid #6d0000;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(180deg, #ff2222, #b50000);
  box-shadow: 0 3px 0 #6d0000;
  padding: 0.5rem 0.2rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #6d0000;
}

.softkey {
  font-size: 0.7rem;
  padding: 0.58rem 0.15rem;
}

.ok-btn {
  font-weight: 700;
}

.typing {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.dot {
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: #d0e7d0;
  animation: pulse 1s infinite ease-in-out;
}

.dot:nth-child(2) {
  animation-delay: 0.15s;
}

.dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

.logout-link {
  color: #e9e9e9;
  font-size: 0.85rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  width: min(340px, 100%);
  background: #1a1a1a;
  border: 1px solid #2b2b2b;
  border-radius: 12px;
  padding: 0.9rem;
}

.modal-card h3 {
  margin: 0 0 0.7rem;
  color: var(--red-bright);
}

.modal-actions {
  margin-top: 0.7rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

@media (min-width: 760px) {
  .admin-grid-form {
    grid-template-columns: repeat(4, 1fr);
    align-items: end;
  }
}
