:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #dbeafe;
    --accent: #0ea5e9;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --sidebar-width: 260px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.sidebar-brand-logo {
    display: block;
    max-width: 180px;
    height: 36px;
    width: auto;
    object-fit: contain;
    margin-bottom: 6px;
}

.sidebar-brand p {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 12px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info { font-size: 12px; color: #94a3b8; margin-bottom: 8px; }
.user-info strong { display: block; color: #e2e8f0; font-size: 13px; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

.page-body { padding: 24px 32px 48px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.primary .value { color: var(--primary); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.success .value { color: var(--success); }
.stat-card.accent .value { color: var(--accent); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
    font-family: inherit;
}

.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-label .optional { font-weight: 400; color: var(--text-muted); }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 44px;
}

/* Tarayıcının kendi şifre göster düğmesini gizle (Chrome/Edge); tek göz ikonu kalsın */
.password-field input[type="password"]::-ms-reveal,
.password-field input[type="password"]::-ms-clear {
    display: none;
}

.password-field input[type="password"]::-webkit-credentials-auto-fill-button,
.password-field input[type="password"]::-webkit-strong-password-auto-fill-button {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: var(--text);
    background: var(--bg);
    outline: none;
}

.password-toggle-icon {
    width: 18px;
    height: 18px;
}

.password-toggle-icon[hidden] {
    display: none;
}

/* Custom select */
.form-select,
.custom-select-trigger {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background-color: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
}

.form-select:hover,
.custom-select-trigger:hover {
    border-color: #cbd5e1;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select option {
    color: var(--text);
    background: var(--surface);
}

/* Custom select dropdown (JS enhanced) */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select.is-open {
    z-index: 60;
}

.custom-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    background-image: none;
}

.custom-select-trigger:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select.is-open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select.is-invalid .custom-select-trigger {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.custom-select.is-disabled .custom-select-trigger {
    opacity: 0.65;
    cursor: not-allowed;
    background: var(--bg);
}

.custom-select-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-value.is-placeholder {
    color: var(--text-muted);
}

.custom-select-chevron {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.custom-select-chevron svg {
    display: block;
    width: 16px;
    height: 16px;
}

.custom-select.is-open .custom-select-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 100%;
    display: flex;
    flex-direction: column;
    max-height: 280px;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 100;
}

.custom-select-search-wrap {
    flex-shrink: 0;
    padding: 6px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.custom-select-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}

.custom-select-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select-options {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px;
}

.custom-select-menu--portaled {
    z-index: 300;
}

.custom-select.is-open .custom-select-menu,
.custom-select-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: 280px;
    padding: 0;
    border-width: 1px;
    overflow: hidden;
    pointer-events: auto;
}

.custom-select:not(.is-open) .custom-select-menu:not(.is-open) {
    max-height: 0;
    padding: 0;
    border-width: 0;
    overflow: hidden;
    pointer-events: none;
}

.custom-select-option.is-hidden {
    display: none;
}

.custom-select-option {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.custom-select-option:hover,
.custom-select-option:focus {
    outline: none;
    background: var(--primary-light);
    color: var(--primary-dark);
}

.custom-select-option.is-selected {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.custom-select-option.is-selected:hover,
.custom-select-option.is-selected:focus {
    background: var(--primary-dark);
    color: #fff;
}

.custom-select-option.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.custom-select-option.is-disabled:hover,
.custom-select-option.is-disabled:focus {
    background: transparent;
    color: var(--text);
}

.custom-select-menu::-webkit-scrollbar {
    width: 8px;
}

.custom-select-menu::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.custom-select-menu::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Custom file upload */
.file-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.file-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-upload-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #fafbfc;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    user-select: none;
}

.file-upload-trigger svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--primary);
}

.file-upload-trigger:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.file-upload-name {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-upload-name.has-file {
    color: var(--text);
    font-weight: 500;
}

.file-upload:focus-within .file-upload-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Filter toolbar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.filter-bar .search-box {
    position: relative;
    flex: 1 1 280px;
    width: auto;
    min-width: 260px;
    max-width: 400px;
}

.filter-bar .search-box input {
    width: 100%;
    padding-left: 36px;
}

.filter-field {
    width: auto;
    flex: 0 1 auto;
    min-width: 0;
}

.filter-field--date {
    width: 168px;
    min-width: 168px;
    flex: 0 0 168px;
}

.filter-field--select {
    width: auto;
    min-width: 196px;
    max-width: 240px;
    flex: 0 0 auto;
}

.filter-field--select-wide {
    width: auto;
    min-width: 220px;
    max-width: 320px;
    flex: 1 1 220px;
}

.filter-bar .custom-select.filter-field--select,
.filter-bar .custom-select.filter-field--select-wide {
    width: auto;
}

.filter-bar .custom-select.filter-field--select {
    min-width: 196px;
    max-width: 240px;
}

.filter-bar .custom-select.filter-field--select-wide {
    min-width: 220px;
    max-width: 320px;
}

.filter-bar .custom-select.filter-field--select-assigned,
.filter-field--select-assigned {
    min-width: 208px;
    max-width: 248px;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.filter-actions .btn {
    white-space: nowrap;
}

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.filter-inline { display: inline-flex; flex-direction: column; gap: 2px; }

/* Yazar detay — dönem filtresi */
.author-period-filter {
    align-items: flex-end;
    gap: 10px;
}

.author-period-filter .filter-inline {
    gap: 4px;
    align-items: flex-start;
}

.author-period-filter .filter-inline > .text-sm {
    line-height: 1.2;
}

.author-period-filter .filter-field--date {
    width: 152px;
    min-width: 152px;
    max-width: 152px;
    flex: none;
    align-self: flex-start;
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1.2;
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    box-sizing: border-box;
}

/* Kanal etiketleri (yazar detay tablosu) */
.report-channel-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.report-channel-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    font-size: 11px;
    line-height: 1.2;
    vertical-align: middle;
}

.report-channel-tag-logo {
    display: block;
    height: 14px;
    width: auto;
    max-width: 48px;
    max-height: 14px;
    object-fit: contain;
    flex-shrink: 0;
}

.report-channel-tag-fallback {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.report-channel-tag-qty {
    font-weight: 600;
    font-size: 11px;
    color: var(--text);
}

.report-channel-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.report-channel-logo {
    height: 16px;
    width: auto;
    max-width: 56px;
    max-height: 16px;
    object-fit: contain;
    flex-shrink: 0;
}

.report-channel-name {
    font-size: 12px;
    font-weight: 500;
}

.inline-assign { display: flex; align-items: center; gap: 6px; }
.inline-assign .form-select { min-width: 150px; max-width: 220px; flex: 1 1 150px; }
.inline-assign .custom-select { width: auto; flex: 1 1 150px; min-width: 150px; max-width: 220px; }
.inline-assign .custom-select-trigger.form-select-sm {
    padding: 4px 28px 4px 8px;
    font-size: 13px;
}
.form-select-sm, .btn-sm.form-select-sm { padding: 4px 8px; font-size: 13px; }

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg);
}
.form-fieldset legend {
    padding: 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* Table */
.table-wrap { overflow-x: auto; overflow-y: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); background: #fafbfc; }
tr:hover td { background: #fafbfc; }
td.actions { white-space: nowrap; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--info-bg); color: #075985; border: 1px solid #bae6fd; }

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-brand-logo {
    display: block;
    max-width: 220px;
    height: 48px;
    width: auto;
    object-fit: contain;
    margin: 0 auto 12px;
}
.auth-brand h1 { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.03em; }
.auth-brand p { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.auth-brand .icon {
    width: 56px; height: 56px;
    background: var(--primary-light);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

/* Setup */
.setup-page { min-height: 100vh; background: var(--bg); padding: 40px 24px; }
.setup-container { max-width: 640px; margin: 0 auto; }
.setup-header { text-align: center; margin-bottom: 32px; }
.setup-brand-logo {
    display: block;
    max-width: 220px;
    height: 44px;
    width: auto;
    object-fit: contain;
    margin: 0 auto 16px;
}
.setup-header h1 { font-size: 26px; font-weight: 800; }
.setup-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.setup-step { flex: 1; height: 4px; background: var(--border); border-radius: 2px; }
.setup-step.active { background: var(--primary); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header .filter-bar {
    order: 1;
    flex: 1 1 100%;
}

.page-header > .btn,
.page-header > a.btn {
    flex-shrink: 0;
    align-self: center;
}

@media (min-width: 900px) {
    .page-header {
        align-items: center;
        flex-wrap: nowrap;
    }

    .page-header .filter-bar {
        order: 0;
        flex: 1 1 auto;
    }
}

.search-box { position: relative; max-width: 320px; }
.search-box input { padding-left: 36px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

@media (max-width: 1024px) {
    .grid-2, .grid-3-1, .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .page-body { padding: 16px; }
    .topbar { padding: 12px 16px; }
}

/* Orders & marketplace */
.orders-stats { margin-bottom: 24px; }

.channel-overview .card-header { padding-bottom: 12px; }

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px 20px 20px;
}

.channel-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafbfc;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
    text-align: center;
}

.channel-card:hover {
    border-color: var(--channel-color, var(--primary));
    box-shadow: var(--shadow);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--text);
}

.channel-card.active {
    border-color: var(--channel-color, var(--primary));
    background: color-mix(in srgb, var(--channel-color, var(--primary)) 8%, white);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--channel-color, var(--primary)) 20%, transparent);
}

.channel-card-logo {
    width: 72px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.channel-card-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: transparent;
}

.channel-fallback {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--channel-color, #64748b) 15%, white);
    color: var(--channel-color, #64748b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.channel-card-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.channel-card strong {
    font-size: 20px;
    letter-spacing: -0.02em;
}

.channel-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.channel-badge-sm {
    padding: 4px 8px 4px 4px;
    font-size: 11px;
}

.channel-badge--logo-only {
    padding: 4px 6px;
    gap: 0;
}

.channel-badge-logo {
    width: 28px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    background: transparent;
}

.channel-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--channel-color, #64748b);
    flex-shrink: 0;
    margin-left: 4px;
}

.orders-table .order-product,
.orders-table .order-book {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-code {
    font-size: 12px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #334155;
}

.row-unmatched td {
    background: #fffbeb;
}

.row-unmatched:hover td {
    background: #fef3c7;
}

.nowrap { white-space: nowrap; }

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.pagination-btn:hover:not(.disabled):not(.active) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}

.pagination-btn.active {
    background: var(--primary, #2563eb);
    border-color: var(--primary, #2563eb);
    color: #fff;
    cursor: default;
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination-ellipsis {
    padding: 0 4px;
    color: #94a3b8;
    font-size: 13px;
}

.sortable-th {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.sortable-th:hover {
    color: var(--primary, #2563eb);
}

.sort-icon {
    font-size: 11px;
    opacity: 0.35;
    line-height: 1;
}

.sort-icon.sort-active {
    opacity: 1;
    color: var(--primary, #2563eb);
}

@media (max-width: 768px) {
    .filter-bar .search-box {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .filter-field--date,
    .filter-field--select,
    .filter-field--select-wide,
    .filter-bar .custom-select.filter-field--select,
    .filter-bar .custom-select.filter-field--select-wide {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .filter-actions {
        flex: 1 1 100%;
    }
}

/* Confirm modal */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.confirm-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.confirm-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.confirm-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 28px 28px 24px;
    text-align: center;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.2s ease;
}

.confirm-modal.is-open .confirm-modal-dialog {
    transform: translateY(0) scale(1);
}

.confirm-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
    line-height: 1;
}

.confirm-modal-icon svg {
    width: 26px;
    height: 26px;
}

.confirm-modal-icon--danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.confirm-modal-icon--primary {
    background: var(--primary-light);
    color: var(--primary);
}

.confirm-modal-icon--warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.confirm-modal-icon--success {
    background: var(--success-bg);
    color: var(--success);
}

.confirm-modal-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    color: var(--text);
}

.confirm-modal-message {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 24px;
}

.confirm-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-modal-actions .btn {
    min-width: 110px;
}

body.confirm-modal-open {
    overflow: hidden;
}

/* Author portal */
.portal-body .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.portal-welcome-title {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.3;
}

.portal-welcome-text {
    margin: 6px 0 0;
    max-width: 640px;
}

.portal-period-card .card-body {
    padding: 16px 20px;
}

.portal-period-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
}

.portal-period-field {
    flex: 0 0 auto;
    min-width: 160px;
    max-width: 200px;
}

.portal-period-field .form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.portal-period-field .form-control {
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
}

.portal-period-actions {
    flex: 0 0 auto;
    padding-bottom: 1px;
}

.portal-period-meta {
    flex: 1 1 100%;
    margin-top: 2px;
}

.portal-toolbar {
    margin-bottom: 16px;
}

.portal-filter-bar {
    width: 100%;
}

.portal-filter-bar .search-box {
    flex: 1 1 220px;
    max-width: 320px;
}

.portal-stats .stat-card .value {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
}

.portal-grid {
    align-items: start;
}

.portal-table tbody tr.portal-row-link {
    cursor: pointer;
}

.portal-table tbody tr.portal-row-link:hover td {
    background: var(--primary-light, #eff6ff);
}

.portal-channel-list {
    padding-top: 4px;
}

.portal-channel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.portal-channel-item:last-child {
    border-bottom: none;
}

.portal-channel-values {
    text-align: right;
    line-height: 1.35;
}

.portal-channel-values .text-sm {
    display: block;
    margin-top: 2px;
}

.portal-back {
    margin-bottom: 16px;
}

.portal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px 20px;
    margin: 0;
}

.portal-detail-grid--single {
    grid-template-columns: 1fr;
}

.portal-detail-item dt {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.portal-detail-item dd {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.portal-detail-highlight {
    color: var(--primary);
    font-size: 1.1rem;
}

.portal-channel-detail {
    display: flex;
    align-items: center;
    gap: 16px;
}

.portal-channel-logo {
    height: 36px;
    width: auto;
    max-width: 80px;
    object-fit: contain;
}

@media (max-width: 768px) {
    .portal-period-field {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
        max-width: none;
    }

    .portal-period-actions {
        flex: 1 1 100%;
    }

    .portal-period-actions .btn {
        width: 100%;
    }

    .portal-filter-bar .search-box {
        flex: 1 1 100%;
        max-width: none;
    }

    .portal-filter-bar .filter-field--select {
        flex: 1 1 100%;
        width: 100%;
    }
}
