:root {
  --bg0: #0f172a;
  --bg1: #1e293b;
  --bg2: #2d3f55;
  --bg3: #3d5068;
  --accent: #38bdf8;
  --purple: #818cf8;
  --green: #34d399;
  --amber: #f59e0b;
  --red: #f87171;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --border: #2d3f55;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --r: 10px;
  --r-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

header {
  background: linear-gradient(135deg, #0a1628, #13223a);
  border-bottom: 1px solid var(--border);
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.06rem;
}

.logo-icon {
  font-size: 1.35rem;
}

.logo-sub {
  display: block;
  font-size: 0.66rem;
  color: var(--text3);
  font-weight: 500;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.user-chip {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  color: var(--text2);
  border: 1px solid var(--border);
  background: var(--bg2);
}

.logout-form {
  margin: 0;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.76rem;
}

.total-badge {
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #0f172a;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

.layout-shell {
  display: flex;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.sidebar {
  width: 360px;
  flex-shrink: 0;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.content-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: start;
  gap: 1rem;
}

.panel-news,
.panel-drafts {
  min-width: 0;
}

.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text2);
  margin-bottom: 0.85rem;
}

.form-grid,
.row {
  display: grid;
  gap: 0.7rem;
}

.row.compact {
  margin-top: 0.65rem;
}

.inline-controls {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.schedule-controls {
  grid-template-columns: minmax(180px, 0.9fr) minmax(220px, 1.1fr) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 0.56rem 0.8rem;
  font-size: 0.85rem;
  outline: none;
  transition: 0.2s;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

textarea {
  min-height: 160px;
  resize: vertical;
}

.btn {
  border: none;
  border-radius: var(--r-sm);
  padding: 0.6rem 1.1rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #0f172a;
}

.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: rgba(52, 211, 153, 0.14);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.28);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.26);
}

.list {
  display: grid;
  gap: 0.95rem;
}

.news-item,
.draft {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.9rem;
}

.image-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  margin: 0.6rem 0 0.4rem;
}

.image-generate-form {
  margin-top: 0.55rem;
}

.img-source {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 0.35rem;
}

.img-source-openai_cloudinary {
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
}

.img-source-source {
  color: var(--text2);
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.12);
}

.img-source-manual {
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
}

.img-source-openai {
  color: var(--purple);
  border: 1px solid rgba(129, 140, 248, 0.35);
  background: rgba(129, 140, 248, 0.12);
}

.item-header {
  margin-bottom: 0.45rem;
}

h3 {
  font-size: 0.96rem;
  margin-bottom: 0.22rem;
  line-height: 1.35;
}

.news-item p {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.5;
  margin: 0.45rem 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--text3);
  font-size: 0.77rem;
}

.ok {
  color: var(--green);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.28);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.6rem;
  margin-top: 0.45rem;
}

.error {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.6rem;
  margin-top: 0.45rem;
}

.warn {
  color: var(--amber);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.6rem;
  margin: 0 0 0.75rem;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
}

.badge-ai {
  background: rgba(129, 140, 248, 0.12);
  color: var(--purple);
  border: 1px solid rgba(129, 140, 248, 0.28);
}

.sources-block {
  margin-top: 0.8rem;
}

.source-list {
  list-style: none;
  display: grid;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.55rem;
}

.source-item a {
  font-size: 0.76rem;
  word-break: break-all;
}

.source-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.login-page {
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(420px, 100%);
}

.login-logo {
  margin-bottom: 0.9rem;
}

@media (max-width: 980px) {
  .layout-shell {
    display: block;
    height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 1rem;
  }

  .content-columns {
    grid-template-columns: 1fr;
  }

  .inline-controls,
  .schedule-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1240px) {
  .content-columns {
    grid-template-columns: 1fr;
  }
}
