* {
    box-sizing: border-box;
}

html {
    background: #f3f4f6;
}

body {
    margin: 0;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: #111827;
    background: #f3f4f6;
}

button,
input {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px 16px;

    background: rgba(255,255,255,.96);
    border-bottom: 1px solid #e5e7eb;
}

.dashboard {
    width: 100%;
    max-width: 720px;

    margin: 0 auto;
    padding: 12px;
}

.card {
    background: white;

    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;

    box-shadow:
        0 1px 3px rgba(0,0,0,.08);
}

.hero-card {
    border-top: 5px solid #111827;
}

h2 {
    margin: 0 0 14px;
    font-size: 15px;
    letter-spacing: .05em;
}

.brand {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: .14em;
}

.brand-small {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .12em;
}

.subtitle {
    margin-bottom: 26px;
    color: #6b7280;
}

.label,
.muted {
    color: #6b7280;
}

.label {
    display: block;
    font-size: 12px;
}

.small {
    font-size: 12px;
}

.big-status {
    font-size: 22px;
    font-weight: 800;
}

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 5px 0;
}

.price-row {
    margin-top: 8px;
    font-size: 22px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.info-grid strong {
    display: block;
    margin-top: 3px;
}

.notice {
    margin-top: 14px;
    padding: 10px;

    border-radius: 10px;

    background: #fff7ed;
    font-size: 13px;
}

.block-row {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.block-row:last-child {
    border-bottom: 0;
}

.pill {
    padding: 5px 10px;
    border-radius: 999px;

    font-size: 12px;
    font-weight: 800;
}

.pill-clear {
    background: #ecfdf5;
}

.pill-block {
    background: #fef2f2;
}

.position-card {
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.position-top {
    display: grid;
    grid-template-columns: 50px 1fr 1fr;
    align-items: center;
}

.position-top strong:last-child {
    text-align: right;
}

.buy {
    font-weight: 800;
}

.sell {
    font-weight: 800;
}

.position-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 12px;

    margin-top: 10px;
    font-size: 13px;
}

.position-grid strong {
    text-align: right;
}

.totals {
    display: grid;
    grid-template-columns: repeat(3,1fr);

    gap: 8px;
    margin-top: 14px;

    text-align: center;
}

.totals div {
    padding: 9px 4px;
    background: #f9fafb;
    border-radius: 10px;
}

.totals span {
    display: block;
    color: #6b7280;
    font-size: 11px;
}

.totals strong {
    display: block;
    margin-top: 3px;
}

.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px 12px;
}

.account-grid strong {
    text-align: right;
}

.control-button,
.emergency-reveal,
.primary-button {
    width: 100%;

    min-height: 48px;
    margin: 5px 0;

    border: 0;
    border-radius: 12px;

    font-weight: 700;
}

.control-button {
    background: #e5e7eb;
}

.emergency-reveal {
    margin-top: 18px;
    background: #f3f4f6;
}

button:disabled {
    opacity: .55;
}

.center {
    text-align: center;
    margin-top: 8px;
}

.empty {
    padding: 22px 0;
    text-align: center;
    color: #9ca3af;
}

.hidden {
    display: none !important;
}

.error-box {
    margin: 12px;
    padding: 12px;

    background: #fef2f2;
    border-radius: 10px;
}

.small-button {
    border: 0;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 8px 10px;
}

.login-body {
    min-height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;

    padding: 28px;

    background: white;
    border-radius: 18px;

    box-shadow:
        0 5px 25px rgba(0,0,0,.08);
}

.login-card label {
    display: block;
    margin: 14px 0;
    font-size: 13px;
}

.login-card input {
    width: 100%;
    min-height: 46px;

    margin-top: 5px;
    padding: 10px;

    border: 1px solid #d1d5db;
    border-radius: 10px;
}

.primary-button {
    margin-top: 12px;

    background: #111827;
    color: white;
}

.message {
    margin-top: 12px;
    text-align: center;
    font-size: 13px;
}

@media (min-width: 700px) {
    .dashboard {
        padding: 20px;
    }

    .card {
        padding: 20px;
    }
}

.control-label {
    margin: 14px 0 8px;
    font-size: 13px;
    font-weight: 700;
}

.timeframe-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin-bottom: 12px;
}

.timeframe-grid button {
    min-height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    font-weight: 700;
}

.timeframe-grid button.selected {
    background: #111827;
    color: white;
    border-color: #111827;
}

.timeframe-grid button:disabled {
    opacity: .45;
}

.period-field {
    display: grid;
    grid-template-columns: 1fr 110px;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.period-field span {
    font-size: 13px;
    font-weight: 700;
}

.period-field input {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    text-align: right;
    font-size: 16px;
}

.emergency-panel {
    margin-top: 10px;
    padding: 14px;

    border: 2px solid #dc2626;
    border-radius: 12px;

    background: #fff7f7;
}

.emergency-warning {
    margin-bottom: 12px;

    text-align: center;

    font-size: 13px;
    font-weight: 800;
    letter-spacing: .04em;
}

.danger-button {
    width: 100%;
    min-height: 54px;

    border: 0;
    border-radius: 12px;

    background: #b91c1c;
    color: white;

    font-weight: 800;
    font-size: 16px;
}

.emergency-cancel {
    width: 100%;
    min-height: 44px;

    margin-top: 8px;

    border: 1px solid #d1d5db;
    border-radius: 10px;

    background: white;

    font-weight: 700;
}

.danger-button:disabled,
.emergency-cancel:disabled {
    opacity: .5;
}


.stop-mode-field {
    display: grid;
    grid-template-columns: 1fr 110px;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.stop-mode-field span {
    font-size: 13px;
    font-weight: 700;
}

.stop-mode-button {
    min-height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    font-weight: 700;
}



.history-card {
    padding: 12px 0;
    border-top: 1px solid #e5e7eb;
}

.history-card:first-child {
    padding-top: 0;
    border-top: 0;
}

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

.history-time {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
    font-size: 13px;
    font-weight: 700;
}

.history-grid {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 5px 10px;
    margin-top: 8px;
    font-size: 13px;
}

.history-grid strong {
    text-align: right;
}


.secondary-button {
    width: 100%;
    margin-top: 8px;
    min-height: 42px;
    border: 1px solid #6b7280;
    border-radius: 8px;
    background: #374151;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
}

.secondary-button:disabled {
    opacity: 0.45;
}


/* Pyramid Remote: main status + operation drawer */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    min-width: 40px;
    min-height: 40px;
    padding: 7px 10px;
    border: 0;
    border-radius: 10px;
    background: #f3f4f6;
    font-size: 20px;
    line-height: 1;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(17, 24, 39, .38);
}

.side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 50;
    width: min(92vw, 430px);
    height: 100dvh;
    overflow-y: auto;
    padding: 14px;
    background: #f3f4f6;
    box-shadow: -8px 0 30px rgba(0,0,0,.18);
    transform: translateX(105%);
    transition: transform .18s ease-out;
}

.side-drawer.open {
    transform: translateX(0);
}

body.drawer-open {
    overflow: hidden;
}

.drawer-header {
    position: sticky;
    top: -14px;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -14px -14px 12px;
    padding: 14px;
    background: rgba(255,255,255,.97);
    border-bottom: 1px solid #e5e7eb;
}

.drawer-title {
    font-size: 18px;
    font-weight: 800;
}

.drawer-header-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.drawer-card {
    margin-bottom: 12px;
    padding: 16px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.drawer-card:last-child {
    margin-bottom: 24px;
}

@media (min-width: 700px) {
    .side-drawer { width: 430px; }
}

