/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0d1117;
    --surface:    #161b22;
    --surface-2:  #21262d;
    --border:     #30363d;
    --border-2:   #3d444d;
    --text:       #e6edf3;
    --text-muted: #8b949e;
    --accent:     #58a6ff;
    --accent-bg:  rgba(88, 166, 255, .12);
    --green:      #3fb950;
    --green-bg:   rgba(63, 185, 80, .12);
    --red:        #f85149;
    --red-bg:     rgba(248, 81, 73, .12);
    --orange:     #ff9900;
    --orange-bg:  rgba(255, 153, 0, .12);
    --yellow:     #d29922;
    --purple:     #bc8cff;
    --purple-bg:  rgba(188, 140, 255, .12);
    --radius-s:   6px;
    --radius-m:   10px;
    --radius-l:   14px;
    --shadow:     0 8px 32px rgba(0, 0, 0, .5);
    --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono:       "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --t:          .15s ease;
}

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: rgba(22, 27, 34, .92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

.header__brand { display: flex; align-items: center; gap: 10px; }

.header__icon { width: 22px; height: 22px; color: var(--accent); }

.header__title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .3px;
}


/* ── Status Dot ────────────────────────────────────────────── */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot--loading { background: var(--yellow); animation: blink 1.2s infinite; }
.status-dot--ok      { background: var(--green); }
.status-dot--error   { background: var(--red); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: .3; }
}

/* ── Main ──────────────────────────────────────────────────── */
.main {
    max-width: 1040px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.tabs__status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 4px;
}
.tabs__status[hidden] { display: none; }

.tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color var(--t), border-color var(--t);
    white-space: nowrap;
}
.tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.tab:hover { color: var(--text); }
.tab--active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tab Panel ─────────────────────────────────────────────── */
.tab-panel { }
.tab-panel.hidden { display: none; }

/* ── Section header ────────────────────────────────────────── */
.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.section__title { font-size: 20px; font-weight: 600; }

/* ── Card Grid ─────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

/* ── DB Card ───────────────────────────────────────────────── */
.db-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    cursor: pointer;
    transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.db-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(88, 166, 255, .1);
}

.db-card__icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-s);
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.db-card__icon svg { width: 20px; height: 20px; }

.db-card__name {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
}
.db-card__meta { font-size: 12px; color: var(--text-muted); }

.db-card__hint {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transition: opacity var(--t);
}
.db-card__hint svg { width: 13px; height: 13px; }
.db-card:hover .db-card__hint { opacity: 1; }

/* ── App Card ──────────────────────────────────────────────── */
.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.app-card:hover {
    border-color: var(--border-2);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}

.app-card__icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-s);
    background: var(--green-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green);
}
.app-card__icon svg { width: 20px; height: 20px; }

.app-card__name {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
}

.app-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.app-card__footer {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
}

/* ── S3 List ──────────────────────────────────────────────── */
.s3-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.s3-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    padding: 16px 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    transition: border-color var(--t), box-shadow var(--t);
}
.s3-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(88, 166, 255, .08);
}

.s3-card__icon {
    width: 28px; height: 28px;
    border-radius: var(--radius-s);
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}
.s3-card__icon svg { width: 14px; height: 14px; }

.s3-card__name {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
    flex: 1;
}
.s3-card__meta { font-size: 12px; color: var(--text-muted); }

/* ── Badge ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--green .badge-dot { background: var(--green); }
.badge--blue  { background: var(--accent-bg); color: var(--accent); }
.badge--blue .badge-dot { background: var(--accent); }
.badge--orange { background: var(--orange-bg); color: var(--orange); }
.badge--gray  { background: var(--surface-2); color: var(--text-muted); }
.badge--purple { background: var(--purple-bg); color: var(--purple); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 72px 24px;
    color: var(--text-muted);
    text-align: center;
}
.empty-state svg { width: 52px; height: 52px; opacity: .3; }
.empty-state p { font-size: 14px; line-height: 1.8; }

/* ── Skeleton ──────────────────────────────────────────────── */
.skeleton-item {
    height: 128px;
    border-radius: var(--radius-m);
    background-image: linear-gradient(
        90deg,
        var(--surface) 0%,
        var(--surface-2) 50%,
        var(--surface) 100%
    );
    background-size: 400% 100%;
    animation: shimmer 1.6s infinite linear;
}
@keyframes shimmer {
    0%   { background-position:  100% 0; }
    100% { background-position: -100% 0; }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-s);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--t), border-color var(--t), opacity var(--t);
    user-select: none;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary {
    background: var(--accent);
    color: #0d1117;
    border-color: var(--accent);
}
.btn--primary:not(:disabled):hover { background: #79b8ff; border-color: #79b8ff; }

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn--ghost:not(:disabled):hover { background: var(--surface-2); color: var(--text); }

.btn--danger {
    background: transparent;
    color: var(--red);
    border-color: var(--border);
    padding: 5px 10px;
    font-size: 12px;
}
.btn--danger:not(:disabled):hover { background: var(--red-bg); border-color: var(--red); }

.btn--sm { padding: 5px 10px; font-size: 12px; }

.btn--icon {
    padding: 6px;
    border-radius: var(--radius-s);
    line-height: 0;
}
.btn--icon svg { width: 15px; height: 15px; }

.btn--vault {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: var(--radius-s);
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--t), color var(--t);
}
.btn--vault:hover {
    background: var(--accent-bg);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
    animation: fade-in .15s ease;
}
.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    width: 100%;
    max-width: 420px;
    margin: 16px;
    box-shadow: var(--shadow);
    animation: slide-up .2s ease;
}
.modal--wide { max-width: 540px; }

@keyframes fade-in  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide-up { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
}
.modal__title { font-size: 16px; font-weight: 600; }

.modal__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-s);
    display: flex;
    transition: color var(--t), background var(--t);
    flex-shrink: 0;
}
.modal__close:hover { color: var(--text); background: var(--surface-2); }
.modal__close svg { width: 18px; height: 18px; }

.modal__body { padding: 20px; }
.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 20px 20px;
}

/* ── Meta Modal ────────────────────────────────────────────── */
.meta-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.meta-header__name {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
}

.meta-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-m);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.meta-icon svg { width: 22px; height: 22px; }
.meta-icon--blue   { background: var(--accent-bg); color: var(--accent); }
.meta-icon--orange { background: var(--orange-bg); color: var(--orange); }
.meta-icon--green  { background: var(--green-bg);  color: var(--green); }

.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.meta-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.meta-item--full { grid-column: 1 / -1; }

.meta-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .7px;
}
.meta-value {
    font-size: 13px;
    color: var(--text);
    font-family: var(--mono);
    word-break: break-all;
}
.meta-value--normal { font-family: var(--font); }

/* ── Form ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 0; }
.form-group + .form-group { margin-top: 16px; }

.form-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.form-label__icon { width: 13px; height: 13px; flex-shrink: 0; }

.form-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    padding: 9px 12px;
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    padding: 9px 36px 9px 12px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    transition: border-color var(--t), box-shadow var(--t);
}
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.form-select option { background: var(--surface-2); }

.form-hint {
    margin-top: 7px;
    font-size: 12px;
    color: var(--text-muted);
}
.form-hint.form-hint--error {
    color: #f85149 !important;
}
/* ── Form checkbox / section ────────────────────────────────── */
.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 10px 14px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    user-select: none;
}
.form-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}
.form-check__label {
    font-size: 13px;
    color: var(--text);
}
.form-check--parent .form-check__label {
    font-weight: 600;
}
.form-check--sub {
    padding-left: 23px;
}
.form-check--sub .form-check__label {
    color: var(--text-muted);
    font-size: 12px;
}

.form-input--readonly {
    cursor: text;
    opacity: .85;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
}
.form-input--error {
    border-color: var(--red);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 15%, transparent);
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toast-in .2s ease;
    pointer-events: all;
    max-width: 320px;
}
.toast--success { border-left: 3px solid var(--green); }
.toast--error   { border-left: 3px solid var(--red); }
.toast__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.toast--success .toast__dot { background: var(--green); }
.toast--error   .toast__dot { background: var(--red); }

@keyframes toast-in { from { transform: translateX(16px); opacity: 0 } to { transform: none; opacity: 1 } }
