:root {
  color-scheme: light;
  --mi-bg: #ffffff;
  --mi-side: #f5f7fa;
  --mi-surface: #ffffff;
  --mi-surface-alt: #f7f9fb;
  --mi-text: #16202c;
  --mi-strong: #0b1a2e;
  --mi-muted: #5a6675;
  --mi-border: #e3e8ee;
  --mi-line: #e9edf2;
  --mi-accent: #0a5c99;
  --mi-accent-soft: #e3ecf5;
  --mi-brand: #0b1a2e;
  --mi-on-brand: #ffffff;
  --mi-brand-icon: #7fd4ff;
  --mi-unread: #0a6fb8;
  --mi-active: #e8f1f9;
  --mi-active-edge: #0b1a2e;
  --mi-group: #f2f5f8;
  --mi-pill: #c9d2dc;
  --mi-danger: #b3261e;
  --mi-hover: #eef2f6;
  --mi-shadow: 0 2px 6px #0b1a2e1f, 0 8px 24px #0b1a2e14;
  --mi-search: #f2f5f8;
  --mi-compose: #0b1a2e;
  --mi-on-compose: #ffffff;
  --mi-toast: #0b1a2e;
  --mi-on-toast: #ffffff;
  --mi-toast-action: #7fd4ff;
  --mi-tag-l: 92%;
  --mi-tag-text-l: 26%;
  --mi-tag-s: 60%;
  font-family: "IBM Plex Sans", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  background: var(--mi-bg);
  color: var(--mi-text);
}

/* tema întunecată Owl Night: bleumarinul mărcii, cyan doar pe acțiunile principale */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --mi-bg: #0b1a2e;
    --mi-side: #0b1a2e;
    --mi-surface: #0f2238;
    --mi-surface-alt: #0b1a2e;
    --mi-text: #e8eff7;
    --mi-strong: #ffffff;
    --mi-muted: #9db0c6;
    --mi-border: #1e3554;
    --mi-line: #1a3050;
    --mi-accent: #6cc8ff;
    --mi-accent-soft: #13294a;
    --mi-brand: #3fb6ff;
    --mi-on-brand: #06223a;
    --mi-brand-icon: #3fb6ff;
    --mi-unread: #3fb6ff;
    --mi-active: #13294a;
    --mi-active-edge: #dce8f5;
    --mi-group: #0b1a2e;
    --mi-pill: #35507a;
    --mi-danger: #ffb4ab;
    --mi-hover: #16304f;
    --mi-shadow: 0 3px 14px #0009;
    --mi-search: #13294a;
    --mi-compose: #3fb6ff;
    --mi-on-compose: #06223a;
    --mi-toast: #e8eff7;
    --mi-on-toast: #0b1a2e;
    --mi-toast-action: #0a5c99;
    --mi-tag-l: 20%;
    --mi-tag-text-l: 80%;
    --mi-tag-s: 45%;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --mi-bg: #0b1a2e;
  --mi-side: #0b1a2e;
  --mi-surface: #0f2238;
  --mi-surface-alt: #0b1a2e;
  --mi-text: #e8eff7;
  --mi-strong: #ffffff;
  --mi-muted: #9db0c6;
  --mi-border: #1e3554;
  --mi-line: #1a3050;
  --mi-accent: #6cc8ff;
  --mi-accent-soft: #13294a;
  --mi-brand: #3fb6ff;
  --mi-on-brand: #06223a;
  --mi-brand-icon: #3fb6ff;
  --mi-unread: #3fb6ff;
  --mi-active: #13294a;
  --mi-active-edge: #dce8f5;
  --mi-group: #0b1a2e;
  --mi-pill: #35507a;
  --mi-danger: #ffb4ab;
  --mi-hover: #16304f;
  --mi-shadow: 0 3px 14px #0009;
  --mi-search: #13294a;
  --mi-compose: #3fb6ff;
  --mi-on-compose: #06223a;
  --mi-toast: #e8eff7;
  --mi-on-toast: #0b1a2e;
  --mi-toast-action: #0a5c99;
  --mi-tag-l: 20%;
  --mi-tag-text-l: 80%;
  --mi-tag-s: 45%;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--mi-bg); color: var(--mi-text); }
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
a { color: var(--mi-accent); }
[hidden] { display: none !important; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--mi-accent); outline-offset: 2px; }

.mi-button {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--mi-border);
  border-radius: 8px;
  background: var(--mi-surface);
  font-weight: 600;
}
.mi-button:hover:not(:disabled) {
  background: var(--mi-hover);
  box-shadow: 0 1px 3px #0002;
}
.mi-button.primary {
  border-color: var(--mi-brand);
  background: var(--mi-brand);
  color: var(--mi-on-brand);
}
.mi-button.danger {
  border-color: var(--mi-danger);
  background: var(--mi-danger);
  color: var(--mi-surface);
}
.mi-button.text {
  border-color: transparent;
  background: transparent;
  color: var(--mi-accent);
}
.mi-icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--mi-muted);
}
.mi-icon-button:hover:not(:disabled) { background: var(--mi-hover); }

input:not([type="checkbox"]):not([type="radio"]),
textarea, select {
  border: 1px solid var(--mi-border);
  border-radius: 8px;
  background: var(--mi-surface);
  padding: 9px 12px;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--mi-accent);
  outline-offset: -1px;
}
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--mi-border); }
th { color: var(--mi-muted); font-weight: 600; text-align: left; }
tr:hover { background: var(--mi-hover); }

.mi-avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 500;
  line-height: 1;
  user-select: none;
}

#mi-loading {
  position: fixed;
  z-index: 3000;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--mi-accent), transparent);
  background-size: 45% 100%;
  animation: mi-loading 1.2s linear infinite;
}
@keyframes mi-loading {
  from { background-position: -50vw 0; }
  to { background-position: 100vw 0; }
}

#toast-region {
  position: fixed;
  z-index: 2500;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 16px;
}
.mi-toast {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 48px;
  max-width: min(520px, calc(100vw - 40px));
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--mi-toast);
  color: var(--mi-on-toast);
  box-shadow: var(--mi-shadow);
}
.mi-toast-action {
  border: 0;
  background: transparent;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--mi-toast-action);
  font-weight: 600;
}

.mi-dialog-backdrop {
  position: fixed;
  z-index: 2200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #0007;
}
.mi-dialog {
  width: 100%;
  padding: 24px;
  border-radius: 14px;
  background: var(--mi-surface);
  box-shadow: var(--mi-shadow);
}
.mi-dialog h2 { margin: 0 0 16px; color: var(--mi-strong); font-size: 20px; font-weight: 600; }
.mi-dialog-body { color: var(--mi-muted); }
.mi-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.mi-popup-menu {
  position: fixed;
  z-index: 2000;
  min-width: 190px;
  max-height: min(500px, 80vh);
  overflow: auto;
  padding: 8px 0;
  border: 1px solid var(--mi-border);
  border-radius: 10px;
  background: var(--mi-surface);
  box-shadow: var(--mi-shadow);
}
.mi-popup-menu hr {
  border: 0;
  border-top: 1px solid var(--mi-border);
  margin: 6px 0;
}
.mi-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  text-align: left;
}
.mi-menu-item:hover { background: var(--mi-hover); }
.mi-menu-item span:nth-child(2) { flex: 1; }

* { scrollbar-color: var(--mi-border) transparent; scrollbar-width: thin; }
