:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-raised: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --muted-strong: #475569;
  --line: #dbe3ef;
  --line-strong: #c7d2e1;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #e6f4f1;
  --green: #15803d;
  --red: #b42318;
  --amber: #b45309;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover,
.button:hover {
  background: var(--primary-hover);
}

button:active,
.button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

.secondary:hover {
  background: var(--surface-soft);
  border-color: #94a3b8;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 22px 32px;
  min-width: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 12px 14px;
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.brand-line {
  display: grid;
  gap: 2px;
  padding-left: 4px;
}

.brand-line strong {
  color: #0f172a;
  font-size: 19px;
  letter-spacing: 0;
  line-height: 1.1;
}

.brand-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.top-nav {
  display: inline-flex;
  gap: 4px;
  justify-content: center;
  justify-self: center;
  padding: 4px;
  background: #edf2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-link {
  min-height: 34px;
  background: transparent;
  color: var(--muted-strong);
  font-weight: 700;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 6px;
  border-color: transparent;
  box-shadow: none;
}

.tab-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.tab-link.active {
  color: #0f172a;
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #0f172a;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 780;
}

h2 {
  color: #0f172a;
  font-size: 15px;
  line-height: 1.2;
  margin-bottom: 16px;
  font-weight: 780;
}

.muted-copy,
#jsonUrl {
  color: var(--muted);
  font-size: 13px;
}

#jsonUrl {
  margin-top: 7px;
  word-break: break-all;
}

.actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.box,
.panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.box,
.panel {
  padding: 18px;
}

.box {
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.box label + label,
.box button {
  margin-top: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px;
  display: grid;
  gap: 10px;
  align-content: space-between;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #94a3b8;
}

.metric-card.ok::before {
  background: var(--green);
}

.metric-card.danger::before {
  background: var(--red);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  color: #0f172a;
  font-size: 32px;
  line-height: 1;
  font-weight: 820;
}

.metric-card.ok strong {
  color: var(--green);
}

.metric-card.danger strong {
  color: var(--red);
}

.metric-card.muted strong {
  color: var(--muted);
}

.dashboard-panel,
.config-panel,
.notifications-panel,
.apps-page {
  margin-bottom: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title h2 {
  margin: 0;
}

.import-inline {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(160px, 240px) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.app-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.app-row {
  width: 100%;
  min-width: 1120px;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(190px, 1.1fr) minmax(230px, 1.2fr) minmax(210px, 0.95fr) auto minmax(185px, auto) auto;
  gap: 14px;
  align-items: center;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  padding: 12px 14px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.app-row:hover,
.app-row.active {
  background: #fbfdff;
  border-color: #94a3b8;
  box-shadow: var(--shadow-soft);
}

.app-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.app-main strong {
  overflow: hidden;
  color: #0f172a;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main small,
.app-url,
.app-date,
.app-firebase small {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.app-url,
.app-firebase small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-date,
.app-firebase {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.app-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.app-actions button {
  min-height: 34px;
  padding-inline: 11px;
}

.notification-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 13px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notification-toolbar {
  max-width: 340px;
  margin-bottom: 14px;
}

.notification-topic-info {
  align-self: end;
  min-height: 38px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.notification-form label:nth-child(2) {
  grid-row: span 2;
}

.weekday-picker {
  display: grid;
  grid-template-columns: repeat(7, auto);
  gap: 8px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.weekday-picker span {
  grid-column: 1 / -1;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 750;
}

.weekday-picker label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.weekday-picker input {
  width: auto;
  accent-color: var(--primary);
}

.notification-form textarea {
  min-height: 104px;
}

.notification-list,
.monitor-list {
  display: grid;
  gap: 8px;
}

.notification-item,
.monitor-item {
  width: 100%;
  display: grid;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.notification-item {
  grid-template-columns: minmax(0, 1fr) auto auto;
  padding: 13px;
}

.monitor-item {
  grid-template-columns: 1fr auto;
  padding: 12px 13px;
}

.notification-item:hover,
.monitor-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.notification-item p {
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
}

.notification-item small,
.monitor-item small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.notification-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
  padding: 12px 0;
}

.status-strip {
  min-height: 38px;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 800;
  font-size: 11px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.neutral {
  background: #f1f5f9;
  color: var(--muted-strong);
  border-color: #d8e1ed;
}

.badge.online {
  background: #eaf8ef;
  color: var(--green);
  border-color: #bfe8cc;
}

.badge.offline {
  background: #fff1f0;
  color: var(--red);
  border-color: #ffd0cc;
}

.badge.warning {
  background: #fff7ed;
  color: var(--amber);
  border-color: #fed7aa;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.editor-side {
  display: grid;
  gap: 16px;
  align-content: start;
}

.editor-section {
  display: none;
}

.editor-section.is-visible {
  display: block;
}

.editor-heading {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

#quickForm,
.firebase-app-panel {
  display: grid;
  gap: 13px;
}

.firebase-app-panel h2 {
  margin-bottom: 2px;
}

.raw-panel {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr;
}

textarea {
  resize: vertical;
  min-height: 540px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.45;
  tab-size: 2;
}

.notification-form textarea,
#firebaseServiceAccountJson,
#appFirebaseServiceAccountJson {
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
}

#firebaseServiceAccountJson,
#appFirebaseServiceAccountJson {
  margin-top: 7px;
  min-height: 150px;
  font-family: Consolas, "Courier New", monospace;
}

.config-panel {
  margin-top: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 13px;
  margin-bottom: 14px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.toggle input {
  width: auto;
  accent-color: var(--primary);
}

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
  transform: translateY(90px);
  opacity: 0;
  transition: 0.2s ease;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 22px;
}

.auth-card {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 14px 0 18px;
}

.auth-card form {
  display: grid;
  gap: 14px;
}

.brand {
  font-size: 18px;
}

#message {
  min-height: 20px;
  margin-top: 14px;
  color: var(--red);
  font-weight: 700;
}

.form-message {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-message.success {
  color: var(--green);
}

.form-message.error {
  color: var(--red);
}

@media (max-width: 960px) {
  .workspace {
    padding: 12px;
  }

  .app-header,
  .topbar,
  .editor-grid,
  .config-grid,
  .import-inline,
  .notification-form,
  .weekday-picker,
  .notification-item {
    grid-template-columns: 1fr;
    display: grid;
  }

  .app-header {
    position: static;
  }

  .top-nav {
    justify-content: start;
    justify-self: stretch;
    overflow-x: auto;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .app-row {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .app-actions,
  .notification-actions,
  .actions {
    flex-wrap: wrap;
    justify-content: start;
  }
}

@media (max-width: 560px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }
}
